{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "7877a446",
   "metadata": {},
   "outputs": [],
   "source": [
    "from math import sqrt\n",
    "import copy\n",
    "import  traceback\n",
    "import shutil\n",
    "import random\n",
    "import numpy as np  # linear algebra\n",
    "import pydicom\n",
    "import os\n",
    "import matplotlib.pyplot as plt\n",
    "import cv2\n",
    "from pydicom.uid import UID\n",
    "from PIL import Image\n",
    "from tqdm import tqdm\n",
    "import openpyxl\n",
    "\n",
    "import torch\n",
    "import torch.nn as nn\n",
    "import torch.nn.functional as F\n",
    "from torch.utils.data import DataLoader, WeightedRandomSampler, Dataset\n",
    "import torchvision.transforms as T\n",
    "from sklearn import metrics\n",
    "import matplotlib.pyplot as plt\n",
    "from data.datasets import AortaDataset3DCenter\n",
    "from model.resnet3d import resnet3d\n",
    "import data.transforms as MT\n",
    "\n",
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "2fbfc2d6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-100 500\n"
     ]
    }
   ],
   "source": [
    "def load_scan(path):\n",
    "    slices = [] #slices = [pydicom.dcmread(path + '/' + s) for s in filter(lambda x: x.endswith('.dcm'), os.listdir(path))]\n",
    "    for s in os.listdir(path):\n",
    "        if os.path.isdir(os.path.join(path, s)): #if not s.endswith('.dcm'):\n",
    "            continue\n",
    "        sl = pydicom.dcmread(os.path.join(path, s), force=True)\n",
    "        try:\n",
    "            sl_p = sl.pixel_array\n",
    "        except AttributeError:\n",
    "            traceback.print_exc()\n",
    "            print(f'\\tDelete {os.path.join(path, s)}')\n",
    "            os.remove(os.path.join(path, s))\n",
    "        else:\n",
    "            slices.append(sl)\n",
    "    slices.sort(key=lambda x: float(x.InstanceNumber))\n",
    "    return slices\n",
    "\n",
    "window_width, window_level = 600, 200\n",
    "lower_b, upper_b = window_level - window_width//2, window_level + window_width//2\n",
    "print(lower_b, upper_b)\n",
    "\n",
    "def time_sync():\n",
    "    # PyTorch-accurate time\n",
    "    if torch.cuda.is_available():\n",
    "        torch.cuda.synchronize()\n",
    "    return time.time()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0c70b0c7",
   "metadata": {},
   "source": [
    "# 1.重命名病人文件夹"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "26795773",
   "metadata": {},
   "outputs": [],
   "source": [
    "dir_list = [\n",
    "#     '/medical-data/zsxm/AorticDissection/dataset/2022-09-12',\n",
    "#     '/medical-data/zsxm/AorticDissection/dataset/2022-10-19',\n",
    "#     '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative'\n",
    "]\n",
    "for ddir in dir_list:\n",
    "    plist = sorted(os.listdir(ddir))\n",
    "    wb = openpyxl.load_workbook(os.path.join(ddir, 'label.xlsx'))\n",
    "    st = wb['Sheet1']\n",
    "    for row in st.iter_rows():\n",
    "        if row[0].value in plist:\n",
    "            #os.rename(os.path.join(ddir, row[0].value), os.path.join(ddir, f'{row[0].value}-{row[3].value}'))\n",
    "            print(os.path.join(ddir, row[0].value), os.path.join(ddir, f'{row[0].value}-{row[3].value}'))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a7b7fcdc",
   "metadata": {},
   "source": [
    "# 2.从dcm生成png图像"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "defe296d",
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "# 将dcm文件根据窗宽窗位转化为png图片\n",
    "dir_list = [\n",
    "#     '/medical-data/zsxm/AorticDissection/dataset/2022-09-12',\n",
    "#     '/medical-data/zsxm/AorticDissection/dataset/2022-10-19',\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative'\n",
    "]\n",
    "for ddir in dir_list:\n",
    "    for patient in tqdm(sorted(os.listdir(ddir))):\n",
    "        pdir = os.path.join(ddir, patient)\n",
    "        if os.path.isfile(pdir):\n",
    "            continue\n",
    "        for cate in ['1', '2']:\n",
    "            cdir = os.path.join(pdir, cate)\n",
    "            image_path = os.path.join(cdir, f'images_{lower_b}_{upper_b}')\n",
    "            if os.path.exists(image_path):\n",
    "                shutil.rmtree(image_path)\n",
    "            os.mkdir(image_path)\n",
    "            ct = load_scan(cdir)\n",
    "            print_flag = False\n",
    "            for i in range(len(ct)):\n",
    "                img = ct[i].pixel_array.astype(np.int16)\n",
    "                intercept = ct[i].RescaleIntercept\n",
    "                slope = ct[i].RescaleSlope\n",
    "                if slope != 1:\n",
    "                    img = (slope * img.astype(np.float64)).astype(np.int16)\n",
    "                img += np.int16(intercept)\n",
    "                img = np.clip(img, lower_b, upper_b)\n",
    "                img = ((img-lower_b)/(upper_b-lower_b)*255).astype(np.uint8)\n",
    "                img = Image.fromarray(img)\n",
    "                if img.height != img.width and not print_flag:\n",
    "                    print(f\"{patient}: height={img.height} and width={img.width} not equal.\")\n",
    "                    print_flag = True\n",
    "                img.save(os.path.join(image_path, f'{patient}_{i:04d}.png'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4d7f3a89",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 将各个病例中的png图片文件夹统一移动到一起供yolov5检测\n",
    "dir_list = [\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/2022-09-12',\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/2022-10-19',\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative'\n",
    "]\n",
    "def move_together_for_detect(input_folder, dst_path):\n",
    "    root_name = os.path.basename(input_folder)\n",
    "    cate_list = ['1', '2']\n",
    "    for cate in cate_list:\n",
    "        os.makedirs(os.path.join(dst_path, cate, root_name), exist_ok=True)\n",
    "\n",
    "    for patient in tqdm(sorted(os.listdir(input_folder)),desc=os.path.basename(input_folder)):\n",
    "        if os.path.isfile(os.path.join(input_folder, patient)):\n",
    "            continue\n",
    "        try:\n",
    "            for cate in cate_list:\n",
    "                if os.path.exists(os.path.join(dst_path, cate, root_name, patient)):\n",
    "                    shutil.rmtree(os.path.join(dst_path, cate, root_name, patient))\n",
    "                shutil.copytree(\n",
    "                    os.path.join(input_folder, patient, cate, f'images_{lower_b}_{upper_b}'),\n",
    "                    os.path.join(dst_path, cate, root_name, patient)\n",
    "                )\n",
    "        except:\n",
    "            traceback.print_exc()\n",
    "            \n",
    "for ddir in dir_list:\n",
    "    move_together_for_detect(ddir, '/medical-data/zsxm/AorticDissection/dataset/9_detect')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "87e5a9ac",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 将yolov5的检测结果（标签和带bounding box的图像）移动回原文件夹\n",
    "def move_back(result_path, ori_path):\n",
    "    cate = os.path.basename(os.path.dirname(result_path))\n",
    "    if not os.path.exists(result_path):\n",
    "        print(f'目录不存在：{result_path}')\n",
    "        return\n",
    "    for patient in tqdm(sorted(os.listdir(result_path))):\n",
    "        #print(f'Processing {patient}')\n",
    "        p_res_path = os.path.join(result_path, patient)\n",
    "        o_res_path = os.path.join(ori_path, patient, cate, f'pred_images_{lower_b}_{upper_b}')\n",
    "        if os.path.exists(o_res_path):\n",
    "            shutil.rmtree(o_res_path)\n",
    "        os.mkdir(o_res_path)\n",
    "        for file in os.listdir(p_res_path):\n",
    "            if os.path.isfile(os.path.join(p_res_path, file)):\n",
    "                shutil.move(os.path.join(p_res_path, file), os.path.join(o_res_path, file))\n",
    "            elif os.path.isdir(os.path.join(p_res_path, file)):\n",
    "                if os.path.exists(os.path.join(ori_path, patient, cate, file)):\n",
    "                    shutil.rmtree(os.path.join(ori_path, patient, cate, file))\n",
    "                shutil.move(os.path.join(p_res_path, file), os.path.join(ori_path, patient, cate, file))\n",
    "        os.rmdir(p_res_path)\n",
    "    os.rmdir(result_path)\n",
    "                \n",
    "move_back(\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/9_detect/pred/1/2022-09-12',\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/',\n",
    ")\n",
    "move_back(\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/9_detect/pred/1/2022-10-19',\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/',\n",
    ")\n",
    "move_back(\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/9_detect/pred/1/2022-10-19-negative',\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/',\n",
    ")\n",
    "\n",
    "move_back(\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/9_detect/pred/2/2022-09-12',\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/',\n",
    ")\n",
    "move_back(\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/9_detect/pred/2/2022-10-19',\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/',\n",
    ")\n",
    "move_back(\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/9_detect/pred/2/2022-10-19-negative',\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/',\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b91af41d",
   "metadata": {},
   "source": [
    "# 3.切出主动脉patch"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "43c0a098",
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "input_path:   0%|                                                                                                                                                       | 0/22 [00:00<?, ?it/s, patient=严立超]/s]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/严立超-122-151-233-611/1/labels/严立超-122-151-233-611_0437.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/严立超-122-151-233-611/1/labels/严立超-122-151-233-611_0438.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/严立超-122-151-233-611/1/labels/严立超-122-151-233-611_0445.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/严立超-122-151-233-611/1/labels/严立超-122-151-233-611_0532.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/严立超-122-151-233-611/1/labels/严立超-122-151-233-611_0533.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/严立超-122-151-233-611/1/labels/严立超-122-151-233-611_0541.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/严立超-122-151-233-611/1/labels/严立超-122-151-233-611_0542.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/严立超-122-151-233-611/1/labels/严立超-122-151-233-611_0543.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/严立超-122-151-233-611/1/labels/严立超-122-151-233-611_0545.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/严立超-122-151-233-611/1/labels/严立超-122-151-233-611_0546.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/严立超-122-151-233-611/1/labels/严立超-122-151-233-611_0547.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/严立超-122-151-233-611/1/labels/严立超-122-151-233-611_0548.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/严立超-122-151-233-611/1/labels/严立超-122-151-233-611_0551.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/严立超-122-151-233-611/1/labels/严立超-122-151-233-611_0552.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/严立超-122-151-233-611/1/labels/严立超-122-151-233-611_0553.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/严立超-122-151-233-611/1/labels/严立超-122-151-233-611_0558.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/严立超-122-151-233-611/1/labels/严立超-122-151-233-611_0559.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/严立超-122-151-233-611/1/labels/严立超-122-151-233-611_0560.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/严立超-122-151-233-611/1/labels/严立超-122-151-233-611_0561.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/严立超-122-151-233-611/1/labels/严立超-122-151-233-611_0562.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/严立超-122-151-233-611/1/labels/严立超-122-151-233-611_0563.txt'\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "input_path:  18%|██████████████████████████                                                                                                                     | 4/22 [00:14<01:00,  3.35s/it, patient=刘俊杰]]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：刘俊杰-24-42-81-321_0054.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：刘俊杰-24-42-81-321_0055.txt\n",
      "input_path:  32%|█████████████████████████████████████████████▌                                                                                                 | 7/22 [00:22<00:41,  2.79s/it, patient=宋大强]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0055.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0056.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0057.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0058.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0059.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0060.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0061.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0062.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0063.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0064.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0065.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0066.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0067.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0068.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0069.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0070.txt\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0071.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0072.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0073.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0074.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0076.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0078.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0079.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0080.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0081.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0082.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0083.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0084.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0085.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0086.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0087.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0088.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0089.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0090.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0091.txt\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0092.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0093.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0094.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0095.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0096.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0097.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0098.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0099.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0100.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0101.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：宋大强-24-53-113-400_0102.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/宋大强-24-53-113-400/1/labels/宋大强-24-53-113-400_0270.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/宋大强-24-53-113-400/1/labels/宋大强-24-53-113-400_0271.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/宋大强-24-53-113-400/1/labels/宋大强-24-53-113-400_0272.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/宋大强-24-53-113-400/1/labels/宋大强-24-53-113-400_0273.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/宋大强-24-53-113-400/1/labels/宋大强-24-53-113-400_0275.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/宋大强-24-53-113-400/1/labels/宋大强-24-53-113-400_0276.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/宋大强-24-53-113-400/1/labels/宋大强-24-53-113-400_0302.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/宋大强-24-53-113-400/1/labels/宋大强-24-53-113-400_0303.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/宋大强-24-53-113-400/1/labels/宋大强-24-53-113-400_0304.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/宋大强-24-53-113-400/1/labels/宋大强-24-53-113-400_0305.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/宋大强-24-53-113-400/1/labels/宋大强-24-53-113-400_0306.txt'\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/宋大强-24-53-113-400/1/labels/宋大强-24-53-113-400_0336.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/宋大强-24-53-113-400/1/labels/宋大强-24-53-113-400_0337.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/宋大强-24-53-113-400/1/labels/宋大强-24-53-113-400_0339.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/宋大强-24-53-113-400/1/labels/宋大强-24-53-113-400_0340.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/宋大强-24-53-113-400/1/labels/宋大强-24-53-113-400_0341.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/宋大强-24-53-113-400/1/labels/宋大强-24-53-113-400_0342.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/宋大强-24-53-113-400/1/labels/宋大强-24-53-113-400_0343.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/宋大强-24-53-113-400/1/labels/宋大强-24-53-113-400_0344.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/宋大强-24-53-113-400/1/labels/宋大强-24-53-113-400_0345.txt'\n",
      "input_path:  36%|████████████████████████████████████████████████████                                                                                           | 8/22 [00:26<00:46,  3.31s/it, patient=张文强]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/张文强-50-65-116-347/1/labels/张文强-50-65-116-347_0167.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 75, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/张文强-50-65-116-347/1/labels/张文强-50-65-116-347_0168.txt'\n",
      "input_path:  50%|███████████████████████████████████████████████████████████████████████                                                                       | 11/22 [00:36<00:36,  3.29s/it, patient=李俊梅]]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：李俊梅-50-73-134-396_0088.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：李俊梅-50-73-134-396_0089.txt\n",
      "input_path:  68%|████████████████████████████████████████████████████████████████████████████████████████████████▊                                             | 15/22 [00:47<00:20,  2.88s/it, patient=肖来元]]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：肖来元-1-26-90-366_0078.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 58, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
      "  File \"/tmp/ipykernel_13221/1444337283.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：肖来元-1-26-90-366_0079.txt\n",
      "input_path: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 22/22 [01:10<00:00,  3.19s/it, patient=黄晶晶]\n",
      "input_path: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 22/22 [02:00<00:00,  5.48s/it, patient=黄晶晶]]s]\n"
     ]
    }
   ],
   "source": [
    "# 切出范围外冗余为3的主动脉，健康数据\n",
    "def find_coordinate(height, width, label_file, aorta):\n",
    "    with open(label_file, 'r') as f:\n",
    "        lines = f.readlines()\n",
    "    assert len(lines) <= 2, f'label.txt应该存储不多于2个label：{label_file.split(\"/\")[-1]}'\n",
    "    if len(lines) == 1:\n",
    "        assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
    "        corr = list(map(lambda x: float(x), lines[0].split()))\n",
    "        x, y, w, h = corr[1], corr[2], corr[3], corr[4]\n",
    "        assert 0.25 < x < 0.75 and 0.2 < y < 0.8, f'边界框中心({x}, {y})出界：{label_file.split(\"/\")[-1]}'\n",
    "    else:\n",
    "        corr1, corr2 = list(map(lambda x: float(x), lines[0].split())), list(map(lambda x: float(x), lines[1].split()))\n",
    "        assert 0.25 < corr1[1] < 0.75 and 0.15 < corr1[2] < 0.85, f'边界框1中心({corr1[1]}, {corr1[2]})出界：{label_file.split(\"/\")[-1]}'\n",
    "        assert 0.25 < corr2[1] < 0.75 and 0.15 < corr2[2] < 0.85, f'边界框2中心({corr2[1]}, {corr2[2]})出界：{label_file.split(\"/\")[-1]}'\n",
    "        if aorta == 's':\n",
    "            x, y, w, h = (corr1[1], corr1[2], corr1[3], corr1[4]) if corr1[2] < corr2[2] else (corr2[1], corr2[2], corr2[3], corr2[4])\n",
    "        elif aorta == 'j':\n",
    "            x, y, w, h = (corr1[1], corr1[2], corr1[3], corr1[4]) if corr1[2] > corr2[2] else (corr2[1], corr2[2], corr2[3], corr2[4])\n",
    "        else:\n",
    "            raise Exception(f'aorta 应该为\"s\"或\"j\"其中之一: {label_file.split(\"/\")[-1]}')\n",
    "    w, h = int(width*w), int(height*h)\n",
    "    w, h = max(w, h), max(w, h)\n",
    "    return int(width*x-w/2), int(height*y-h/2), int(width*x+w/2+1), int(height*y+h/2+1)\n",
    "\n",
    "def crop_images(input_path, error_patient_list, cate):\n",
    "    workbook_path = os.path.join(input_path, 'label.xlsx')\n",
    "    wb = openpyxl.load_workbook(workbook_path)\n",
    "    sheet = wb['Sheet1']\n",
    "    \n",
    "    patientList = [p for p in os.listdir(input_path) if os.path.isdir(os.path.join(input_path, p))]\n",
    "    pbar = tqdm(sorted(patientList), desc=os.path.basename('input_path'))\n",
    "    for patient in pbar:\n",
    "        pbar.set_postfix({'patient': patient.split('-')[0]})\n",
    "        for row in sheet.iter_rows():\n",
    "            if row[0].value == patient.split('-')[0]:\n",
    "                if cate == '1': col = 3\n",
    "                elif cate == '2': col = 4\n",
    "                else: raise ValueError(f'cate wrong: {cate}')\n",
    "                ls = row[col].value.split('-')\n",
    "                assert len(ls) == 4, f'{patient} ls wrong: {ls}'\n",
    "                aorta_start, branch_start = int(ls[0])-1, int(ls[1])-1\n",
    "                branch_end, aorta_end = int(ls[2])-1, int(ls[3])-1\n",
    "                break\n",
    "        image_path = os.path.join(input_path, patient, cate, f'images_{lower_b}_{upper_b}')\n",
    "        label_path = os.path.join(input_path, patient, cate, 'labels')\n",
    "        crop_path = os.path.join(input_path, patient, cate, f'crops3d_{lower_b}_{upper_b}')\n",
    "        if os.path.exists(crop_path):\n",
    "            shutil.rmtree(crop_path)\n",
    "        os.mkdir(crop_path)\n",
    "        \n",
    "        crop_flag = True\n",
    "        offset = branch_end - branch_start\n",
    "        start, end = branch_start + int(0.1*offset), branch_end - int(0.2*offset)\n",
    "        for i in range(start-3, end+3):\n",
    "            try:\n",
    "                img = Image.open(os.path.join(image_path, f'{patient}_{i:04d}.png'))\n",
    "                img = np.array(img)\n",
    "                x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 's')\n",
    "            except:\n",
    "                traceback.print_exc()\n",
    "                crop_flag = False\n",
    "            else:#if crop_flag:\n",
    "                crop = img[y1:y2, x1:x2]\n",
    "                crop = Image.fromarray(crop)\n",
    "                if start <= i < end:\n",
    "                    crop.save(os.path.join(crop_path, f'{patient}_s_{i:04d}.png'))\n",
    "                else:\n",
    "                    crop.save(os.path.join(crop_path, f'{patient}_s_{i:04d}_n.png'))\n",
    "        offset = aorta_end - branch_start\n",
    "        start, end = branch_start + int(0.05*offset), aorta_end - int(0.1*offset)\n",
    "        for i in range(start-3, end+3):\n",
    "            try:\n",
    "                img = Image.open(os.path.join(image_path, f'{patient}_{i:04d}.png'))\n",
    "                img = np.array(img)\n",
    "                x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{i:04d}.txt'), 'j')\n",
    "            except:\n",
    "                traceback.print_exc()\n",
    "                crop_flag = False\n",
    "            else:#if crop_flag:\n",
    "                crop = img[y1:y2, x1:x2]\n",
    "                crop = Image.fromarray(crop)\n",
    "                if start <= i < end:\n",
    "                    crop.save(os.path.join(crop_path, f'{patient}_j_{i:04d}.png'))\n",
    "                else:\n",
    "                    crop.save(os.path.join(crop_path, f'{patient}_j_{i:04d}_n.png'))\n",
    "        if not crop_flag:\n",
    "            error_patient_list.append(patient)\n",
    "    pbar.close()\n",
    "\n",
    "el1 = []\n",
    "crop_images('/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/', el1, '1')\n",
    "el2 = []\n",
    "crop_images('/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative/', el2, '2')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "336b73a6",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "input_path:   4%|█████                                                                                                                                        | 1/28 [00:00<00:16,  1.67it/s, patient=fangdali]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：fangdali-S-17-26-J-18-89_0013.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：fangdali-S-17-26-J-18-89_0014.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：fangdali-S-17-26-J-18-89_0015.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/fangdali-S-17-26-J-18-89/1/labels/fangdali-S-17-26-J-18-89_0091.txt'\n",
      "input_path:   7%|█████████▉                                                                                                                                 | 2/28 [00:01<00:19,  1.32it/s, patient=heyongming]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：heyongming-S-21-32-J-21-63_0017.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：heyongming-S-21-32-J-21-63_0018.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：heyongming-S-21-32-J-21-63_0019.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：heyongming-S-21-32-J-21-63_0034.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 58, in crop_images\n",
      "    img = Image.open(os.path.join(image_path, f'{patient}_{j:04d}.png'))\n",
      "  File \"/home/zsxm/miniconda3/envs/pytorch/lib/python3.7/site-packages/PIL/Image.py\", line 2953, in open\n",
      "    fp = builtins.open(filename, \"rb\")\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/heyongming-S-21-32-J-21-63/1/images_-100_500/heyongming-S-21-32-J-21-63_0063.png'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 58, in crop_images\n",
      "    img = Image.open(os.path.join(image_path, f'{patient}_{j:04d}.png'))\n",
      "  File \"/home/zsxm/miniconda3/envs/pytorch/lib/python3.7/site-packages/PIL/Image.py\", line 2953, in open\n",
      "    fp = builtins.open(filename, \"rb\")\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/heyongming-S-21-32-J-21-63/1/images_-100_500/heyongming-S-21-32-J-21-63_0064.png'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 58, in crop_images\n",
      "    img = Image.open(os.path.join(image_path, f'{patient}_{j:04d}.png'))\n",
      "  File \"/home/zsxm/miniconda3/envs/pytorch/lib/python3.7/site-packages/PIL/Image.py\", line 2953, in open\n",
      "    fp = builtins.open(filename, \"rb\")\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/heyongming-S-21-32-J-21-63/1/images_-100_500/heyongming-S-21-32-J-21-63_0065.png'\n",
      "input_path:  11%|███████████████                                                                                                                             | 3/28 [00:02<00:17,  1.44it/s, patient=huangyuan]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 58, in crop_images\n",
      "    img = Image.open(os.path.join(image_path, f'{patient}_{j:04d}.png'))\n",
      "  File \"/home/zsxm/miniconda3/envs/pytorch/lib/python3.7/site-packages/PIL/Image.py\", line 2953, in open\n",
      "    fp = builtins.open(filename, \"rb\")\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/huangyuan-J-24-70/1/images_-100_500/huangyuan-J-24-70_0070.png'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 58, in crop_images\n",
      "    img = Image.open(os.path.join(image_path, f'{patient}_{j:04d}.png'))\n",
      "  File \"/home/zsxm/miniconda3/envs/pytorch/lib/python3.7/site-packages/PIL/Image.py\", line 2953, in open\n",
      "    fp = builtins.open(filename, \"rb\")\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/huangyuan-J-24-70/1/images_-100_500/huangyuan-J-24-70_0071.png'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 58, in crop_images\n",
      "    img = Image.open(os.path.join(image_path, f'{patient}_{j:04d}.png'))\n",
      "  File \"/home/zsxm/miniconda3/envs/pytorch/lib/python3.7/site-packages/PIL/Image.py\", line 2953, in open\n",
      "    fp = builtins.open(filename, \"rb\")\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/huangyuan-J-24-70/1/images_-100_500/huangyuan-J-24-70_0072.png'\n",
      "input_path:  14%|████████████████████▏                                                                                                                        | 4/28 [00:02<00:13,  1.80it/s, patient=jiangyun]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/jiangyun-J-12-87/1/labels/jiangyun-J-12-87_0087.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/jiangyun-J-12-87/1/labels/jiangyun-J-12-87_0088.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/jiangyun-J-12-87/1/labels/jiangyun-J-12-87_0089.txt'\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "input_path:  21%|██████████████████████████████                                                                                                              | 6/28 [00:03<00:13,  1.67it/s, patient=liushijie]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：liushijie-S-23-37-J-23-37_0019.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：liushijie-S-23-37-J-23-37_0020.txt\n",
      "input_path:  25%|███████████████████████████████████▎                                                                                                         | 7/28 [00:04<00:10,  1.92it/s, patient=liyubing]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/liyubing-J-13-61/1/labels/liyubing-J-13-61_0061.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/liyubing-J-13-61/1/labels/liyubing-J-13-61_0062.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/liyubing-J-13-61/1/labels/liyubing-J-13-61_0063.txt'\n",
      "input_path:  29%|███████████████████████████████████████▏                                                                                                 | 8/28 [00:04<00:09,  2.02it/s, patient=loushenghong]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：loushenghong-S-22-34_0018.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：loushenghong-S-22-34_0019.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：loushenghong-S-22-34_0020.txt\n",
      "input_path:  39%|██████████████████████████████████████████████████████▌                                                                                    | 11/28 [00:05<00:05,  2.95it/s, patient=shenchuan]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：shenchuan-S-13-19-J-13-80_0009.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：shenchuan-S-13-19-J-13-80_0010.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：shenchuan-S-13-19-J-13-80_0011.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/shenchuan-S-13-19-J-13-80/1/labels/shenchuan-S-13-19-J-13-80_0082.txt'\n",
      "input_path:  43%|███████████████████████████████████████████████████████████▏                                                                              | 12/28 [00:06<00:07,  2.17it/s, patient=wanshuqiao]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：wanshuqiao-S-24-37-J-24-91_0020.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：wanshuqiao-S-24-37-J-24-91_0021.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/wanshuqiao-S-24-37-J-24-91/1/labels/wanshuqiao-S-24-37-J-24-91_0091.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/wanshuqiao-S-24-37-J-24-91/1/labels/wanshuqiao-S-24-37-J-24-91_0092.txt'\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "input_path:  50%|████████████████████████████████████████████████████████████████████████                                                                        | 14/28 [00:06<00:06,  2.23it/s, patient=wufu]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：wufu-S-23-35-J-23-94_0019.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：wufu-S-23-35-J-23-94_0020.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：wufu-S-23-35-J-23-94_0021.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/wufu-S-23-35-J-23-94/1/labels/wufu-S-23-35-J-23-94_0096.txt'\n",
      "input_path:  61%|███████████████████████████████████████████████████████████████████████████████████▊                                                      | 17/28 [00:08<00:04,  2.41it/s, patient=yangguihua]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yangguihua-J-16-61-J-70-78/1/labels/yangguihua-J-16-61-J-70-78_0046.txt'\n",
      "input_path:  64%|████████████████████████████████████████████████████████████████████████████████████████                                                 | 18/28 [00:08<00:04,  2.21it/s, patient=yangshiping]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yangshiping-S-31-34-J23-91/1/labels/yangshiping-S-31-34-J23-91_0043.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yangshiping-S-31-34-J23-91/1/labels/yangshiping-S-31-34-J23-91_0044.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yangshiping-S-31-34-J23-91/1/labels/yangshiping-S-31-34-J23-91_0045.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yangshiping-S-31-34-J23-91/1/labels/yangshiping-S-31-34-J23-91_0047.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yangshiping-S-31-34-J23-91/1/labels/yangshiping-S-31-34-J23-91_0048.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yangshiping-S-31-34-J23-91/1/labels/yangshiping-S-31-34-J23-91_0049.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yangshiping-S-31-34-J23-91/1/labels/yangshiping-S-31-34-J23-91_0052.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yangshiping-S-31-34-J23-91/1/labels/yangshiping-S-31-34-J23-91_0054.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yangshiping-S-31-34-J23-91/1/labels/yangshiping-S-31-34-J23-91_0055.txt'\n",
      "input_path:  71%|██████████████████████████████████████████████████████████████████████████████████████████████████▌                                       | 20/28 [00:10<00:05,  1.37it/s, patient=yejianfeng]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yejianfeng-J-19-101/1/labels/yejianfeng-J-19-101_0015.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yejianfeng-J-19-101/1/labels/yejianfeng-J-19-101_0016.txt'\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yejianfeng-J-19-101/1/labels/yejianfeng-J-19-101_0102.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yejianfeng-J-19-101/1/labels/yejianfeng-J-19-101_0103.txt'\n",
      "input_path:  75%|████████████████████████████████████████████████████████████████████████████████████████████████████████▎                                  | 21/28 [00:11<00:05,  1.28it/s, patient=yikeliang]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 58, in crop_images\n",
      "    img = Image.open(os.path.join(image_path, f'{patient}_{j:04d}.png'))\n",
      "  File \"/home/zsxm/miniconda3/envs/pytorch/lib/python3.7/site-packages/PIL/Image.py\", line 2953, in open\n",
      "    fp = builtins.open(filename, \"rb\")\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yikeliang-J-1-55/1/images_-100_500/yikeliang-J-1-55_-003.png'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 58, in crop_images\n",
      "    img = Image.open(os.path.join(image_path, f'{patient}_{j:04d}.png'))\n",
      "  File \"/home/zsxm/miniconda3/envs/pytorch/lib/python3.7/site-packages/PIL/Image.py\", line 2953, in open\n",
      "    fp = builtins.open(filename, \"rb\")\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yikeliang-J-1-55/1/images_-100_500/yikeliang-J-1-55_-002.png'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 58, in crop_images\n",
      "    img = Image.open(os.path.join(image_path, f'{patient}_{j:04d}.png'))\n",
      "  File \"/home/zsxm/miniconda3/envs/pytorch/lib/python3.7/site-packages/PIL/Image.py\", line 2953, in open\n",
      "    fp = builtins.open(filename, \"rb\")\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yikeliang-J-1-55/1/images_-100_500/yikeliang-J-1-55_-001.png'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yikeliang-J-1-55/1/labels/yikeliang-J-1-55_0055.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yikeliang-J-1-55/1/labels/yikeliang-J-1-55_0056.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yikeliang-J-1-55/1/labels/yikeliang-J-1-55_0057.txt'\n",
      "input_path:  79%|██████████████████████████████████████████████████████████████████████████████████████████████████████████▊                             | 22/28 [00:12<00:04,  1.38it/s, patient=yushengliang]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yushengliang-S-22-31-J-22-88/1/labels/yushengliang-S-22-31-J-22-88_0018.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：yushengliang-S-22-31-J-22-88_0019.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：yushengliang-S-22-31-J-22-88_0022.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yushengliang-S-22-31-J-22-88/1/labels/yushengliang-S-22-31-J-22-88_0018.txt'\n",
      "input_path:  89%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏              | 25/28 [00:14<00:01,  1.50it/s, patient=zhengxuyan]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：zhengxuyan-S-15-32-J-15-48_0011.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：zhengxuyan-S-15-32-J-15-48_0012.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：zhengxuyan-S-15-32-J-15-48_0013.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：zhengxuyan-S-15-32-J-15-48_0023.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：zhengxuyan-S-15-32-J-15-48_0025.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：zhengxuyan-S-15-32-J-15-48_0026.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：zhengxuyan-S-15-32-J-15-48_0027.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：zhengxuyan-S-15-32-J-15-48_0028.txt\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：zhengxuyan-S-15-32-J-15-48_0029.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：zhengxuyan-S-15-32-J-15-48_0030.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0031.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0032.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0033.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0034.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0031.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0032.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0033.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0034.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0035.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0036.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0037.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0038.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0039.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0040.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0041.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0042.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0043.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0044.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0045.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0046.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0047.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0048.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0049.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/1/labels/zhengxuyan-S-15-32-J-15-48_0050.txt'\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "input_path:  93%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████          | 26/28 [00:15<00:01,  1.50it/s, patient=zhongwei]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：zhongwei-S-22-32-J-22-84_0018.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：zhongwei-S-22-32-J-22-84_0019.txt\n",
      "input_path:  96%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏    | 27/28 [00:15<00:00,  1.36it/s, patient=zhuguangzhong]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhuguangzhong-J-41-84/1/labels/zhuguangzhong-J-41-84_0086.txt'\n",
      "input_path: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 28/28 [00:16<00:00,  1.69it/s, patient=zhuguangzhong]\n",
      "input_path:  11%|███████████████▉                                                                                                                               | 2/18 [00:08<01:11,  4.49s/it, patient=吴银春]/s]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/吴银春-J-84-162-J-284-413/1/labels/吴银春-J-84-162-J-284-413_0335.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/吴银春-J-84-162-J-284-413/1/labels/吴银春-J-84-162-J-284-413_0336.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/吴银春-J-84-162-J-284-413/1/labels/吴银春-J-84-162-J-284-413_0337.txt'\n",
      "input_path:  17%|███████████████████████▊                                                                                                                       | 3/18 [00:10<00:51,  3.47s/it, patient=周菲菲]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：周菲菲-S-73-143-J-73-304_0069.txt\n",
      "input_path:  22%|███████████████████████████████▊                                                                                                               | 4/18 [00:13<00:45,  3.25s/it, patient=寿培旺]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0061.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0062.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0066.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0067.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0068.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 13, in find_coordinate\n",
      "    assert 0.25 < corr1[1] < 0.75 and 0.15 < corr1[2] < 0.85, f'边界框1中心({corr1[1]}, {corr1[2]})出界：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 边界框1中心(0.233398, 0.443359)出界：寿培旺-J-52-115-J-222-386_0070.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0076.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0077.txt'\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0078.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0089.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0092.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0093.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0094.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0095.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0096.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0097.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0098.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0099.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0102.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0103.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0110.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0111.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0116.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0218.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0219.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0222.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0223.txt'\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0226.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0227.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0229.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0230.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0231.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0232.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0233.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0234.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0249.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0250.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0251.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0252.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0253.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0254.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0255.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0256.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0257.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0258.txt'\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0283.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0285.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0286.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0287.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0291.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0296.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0302.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0303.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0304.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0305.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0306.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0307.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0308.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0309.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0310.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0311.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0315.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0316.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0317.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0318.txt'\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0319.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0320.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0321.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0322.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0323.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0324.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0325.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0352.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0353.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0354.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0355.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0356.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0357.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0358.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0359.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0360.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0361.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0362.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0366.txt'\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0369.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0370.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0375.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0376.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0377.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0378.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0379.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0380.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0381.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0382.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0383.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0384.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0385.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0386.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0387.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/1/labels/寿培旺-J-52-115-J-222-386_0388.txt'\n",
      "input_path:  28%|███████████████████████████████████████▋                                                                                                       | 5/18 [00:16<00:41,  3.18s/it, patient=屠光明]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/屠光明-J-64-382/1/labels/屠光明-J-64-382_0384.txt'\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "input_path:  33%|████████████████████████████████████████████████▎                                                                                                | 6/18 [00:20<00:39,  3.31s/it, patient=张彪]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/张彪-J-59-140-J-262-444/1/labels/张彪-J-59-140-J-262-444_0391.txt'\n",
      "input_path:  44%|███████████████████████████████████████████████████████████████▌                                                                               | 8/18 [00:25<00:28,  2.80s/it, patient=徐公领]]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/徐公领-J-47-427/1/labels/徐公领-J-47-427_0223.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/徐公领-J-47-427/1/labels/徐公领-J-47-427_0224.txt'\n",
      "input_path:  50%|███████████████████████████████████████████████████████████████████████▌                                                                       | 9/18 [00:30<00:30,  3.43s/it, patient=曹效石]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：曹效石-S-74-98-J-74-93_0070.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：曹效石-S-74-98-J-74-93_0071.txt\n",
      "input_path:  56%|██████████████████████████████████████████████████████████████████████████████▉                                                               | 10/18 [00:30<00:20,  2.60s/it, patient=朱俊行]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：朱俊行-S-73-88-J-73-383_0069.txt\n",
      "input_path:  72%|██████████████████████████████████████████████████████████████████████████████████████████████████████▌                                       | 13/18 [00:40<00:15,  3.03s/it, patient=葛秋英]]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0024.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0025.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0026.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0027.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0028.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0029.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0030.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0031.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0032.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0033.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0034.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0035.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0036.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0037.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0038.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0039.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0040.txt\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0042.txt\n",
      "input_path:  78%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████▍                               | 14/18 [00:41<00:09,  2.43s/it, patient=董爱琴]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0036.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0037.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0038.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0039.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0040.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0041.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0042.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0043.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0044.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0045.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0046.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0047.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0048.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0049.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0050.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0051.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0052.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0053.txt\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "input_path: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 18/18 [00:53<00:00,  2.99s/it, patient=黄锦元]\n",
      "input_path:   0%|                                                                                                                                                  | 0/28 [00:00<?, ?it/s, patient=chenjianbin]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/chenjianbin-J-16-83/2/labels/chenjianbin-J-16-83_0084.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/chenjianbin-J-16-83/2/labels/chenjianbin-J-16-83_0085.txt'\n",
      "input_path:   4%|█████                                                                                                                                        | 1/28 [00:01<00:33,  1.23s/it, patient=fangdali]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：fangdali-S-17-26-J-18-89_0014.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：fangdali-S-17-26-J-18-89_0015.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：fangdali-S-17-26-J-18-89_0016.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/fangdali-S-17-26-J-18-89/2/labels/fangdali-S-17-26-J-18-89_0092.txt'\n",
      "input_path:   7%|█████████▉                                                                                                                                 | 2/28 [00:02<00:34,  1.35s/it, patient=heyongming]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：heyongming-S-21-32-J-21-63_0018.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：heyongming-S-21-32-J-21-63_0019.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：heyongming-S-21-32-J-21-63_0034.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：heyongming-S-21-32-J-21-63_0035.txt\n",
      "input_path:  14%|████████████████████▏                                                                                                                        | 4/28 [00:03<00:19,  1.22it/s, patient=jiangyun]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/jiangyun-J-12-87/2/labels/jiangyun-J-12-87_0093.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/jiangyun-J-12-87/2/labels/jiangyun-J-12-87_0094.txt'\n",
      "input_path:  21%|██████████████████████████████                                                                                                              | 6/28 [00:05<00:17,  1.26it/s, patient=liushijie]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：liushijie-S-23-37-J-23-37_0017.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：liushijie-S-23-37-J-23-37_0018.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：liushijie-S-23-37-J-23-37_0019.txt\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "input_path:  25%|███████████████████████████████████▎                                                                                                         | 7/28 [00:05<00:14,  1.49it/s, patient=liyubing]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/liyubing-J-13-61/2/labels/liyubing-J-13-61_0086.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/liyubing-J-13-61/2/labels/liyubing-J-13-61_0087.txt'\n",
      "input_path:  29%|███████████████████████████████████████▏                                                                                                 | 8/28 [00:06<00:14,  1.41it/s, patient=loushenghong]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：loushenghong-S-22-34_0017.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：loushenghong-S-22-34_0018.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：loushenghong-S-22-34_0019.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：loushenghong-S-22-34_0035.txt\n",
      "input_path:  39%|██████████████████████████████████████████████████████▌                                                                                    | 11/28 [00:07<00:07,  2.25it/s, patient=shenchuan]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：shenchuan-S-13-19-J-13-80_0009.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：shenchuan-S-13-19-J-13-80_0010.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：shenchuan-S-13-19-J-13-80_0011.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/shenchuan-S-13-19-J-13-80/2/labels/shenchuan-S-13-19-J-13-80_0081.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/shenchuan-S-13-19-J-13-80/2/labels/shenchuan-S-13-19-J-13-80_0082.txt'\n",
      "input_path:  46%|████████████████████████████████████████████████████████████████                                                                          | 13/28 [00:08<00:07,  2.09it/s, patient=wanshuqiao]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：wanshuqiao-S-24-37-J-24-91_0018.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：wanshuqiao-S-24-37-J-24-91_0019.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：wanshuqiao-S-24-37-J-24-91_0020.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/wanshuqiao-S-24-37-J-24-91/2/labels/wanshuqiao-S-24-37-J-24-91_0090.txt'\n",
      "input_path:  50%|████████████████████████████████████████████████████████████████████████                                                                        | 14/28 [00:09<00:09,  1.49it/s, patient=wufu]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：wufu-S-23-35-J-23-94_0019.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：wufu-S-23-35-J-23-94_0020.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：wufu-S-23-35-J-23-94_0021.txt\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "input_path:  61%|███████████████████████████████████████████████████████████████████████████████████▊                                                      | 17/28 [00:11<00:06,  1.76it/s, patient=yangguihua]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yangguihua-J-16-61-J-70-78/2/labels/yangguihua-J-16-61-J-70-78_0079.txt'\n",
      "input_path:  68%|█████████████████████████████████████████████████████████████████████████████████████████████████                                              | 19/28 [00:13<00:06,  1.46it/s, patient=yehui]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yehui-J-14-83/2/labels/yehui-J-14-83_0083.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yehui-J-14-83/2/labels/yehui-J-14-83_0084.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yehui-J-14-83/2/labels/yehui-J-14-83_0085.txt'\n",
      "input_path:  71%|██████████████████████████████████████████████████████████████████████████████████████████████████▌                                       | 20/28 [00:14<00:05,  1.38it/s, patient=yejianfeng]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yejianfeng-J-19-101/2/labels/yejianfeng-J-19-101_0016.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yejianfeng-J-19-101/2/labels/yejianfeng-J-19-101_0102.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yejianfeng-J-19-101/2/labels/yejianfeng-J-19-101_0103.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yejianfeng-J-19-101/2/labels/yejianfeng-J-19-101_0104.txt'\n",
      "input_path:  79%|██████████████████████████████████████████████████████████████████████████████████████████████████████████▊                             | 22/28 [00:19<00:11,  1.94s/it, patient=yushengliang]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yushengliang-S-22-31-J-22-88/2/labels/yushengliang-S-22-31-J-22-88_0018.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：yushengliang-S-22-31-J-22-88_0021.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：yushengliang-S-22-31-J-22-88_0022.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：yushengliang-S-22-31-J-22-88_0023.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：yushengliang-S-22-31-J-22-88_0024.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/yushengliang-S-22-31-J-22-88/2/labels/yushengliang-S-22-31-J-22-88_0018.txt'\n",
      "input_path:  89%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏              | 25/28 [00:22<00:03,  1.20s/it, patient=zhengxuyan]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：zhengxuyan-S-15-32-J-15-48_0011.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：zhengxuyan-S-15-32-J-15-48_0012.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：zhengxuyan-S-15-32-J-15-48_0013.txt\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：zhengxuyan-S-15-32-J-15-48_0031.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/2/labels/zhengxuyan-S-15-32-J-15-48_0032.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/2/labels/zhengxuyan-S-15-32-J-15-48_0033.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：zhengxuyan-S-15-32-J-15-48_0034.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/2/labels/zhengxuyan-S-15-32-J-15-48_0032.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/2/labels/zhengxuyan-S-15-32-J-15-48_0033.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/2/labels/zhengxuyan-S-15-32-J-15-48_0038.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/2/labels/zhengxuyan-S-15-32-J-15-48_0039.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/2/labels/zhengxuyan-S-15-32-J-15-48_0040.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/2/labels/zhengxuyan-S-15-32-J-15-48_0041.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/2/labels/zhengxuyan-S-15-32-J-15-48_0042.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/2/labels/zhengxuyan-S-15-32-J-15-48_0043.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/2/labels/zhengxuyan-S-15-32-J-15-48_0044.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/2/labels/zhengxuyan-S-15-32-J-15-48_0045.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/2/labels/zhengxuyan-S-15-32-J-15-48_0046.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/2/labels/zhengxuyan-S-15-32-J-15-48_0047.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/2/labels/zhengxuyan-S-15-32-J-15-48_0048.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/2/labels/zhengxuyan-S-15-32-J-15-48_0049.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhengxuyan-S-15-32-J-15-48/2/labels/zhengxuyan-S-15-32-J-15-48_0050.txt'\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "input_path:  93%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████          | 26/28 [00:22<00:02,  1.02s/it, patient=zhongwei]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：zhongwei-S-22-32-J-22-84_0018.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：zhongwei-S-22-32-J-22-84_0019.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：zhongwei-S-22-32-J-22-84_0020.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhongwei-S-22-32-J-22-84/2/labels/zhongwei-S-22-32-J-22-84_0087.txt'\n",
      "input_path:  96%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏    | 27/28 [00:23<00:00,  1.01it/s, patient=zhuguangzhong]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-09-12/zhuguangzhong-J-41-84/2/labels/zhuguangzhong-J-41-84_0084.txt'\n",
      "input_path: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 28/28 [00:24<00:00,  1.15it/s, patient=zhuguangzhong]\n",
      "input_path:   0%|                                                                                                                                                       | 0/18 [00:00<?, ?it/s, patient=于梦博]/s]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：于梦博-S-69-91-J-69-356_0062.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：于梦博-S-69-91-J-69-356_0063.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：于梦博-S-69-91-J-69-356_0064.txt\n",
      "input_path:   6%|███████▉                                                                                                                                       | 1/18 [00:03<01:00,  3.56s/it, patient=史新泉]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：史新泉-S-71-111-J-75-413_0067.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：史新泉-S-71-111-J-75-413_0068.txt\n",
      "input_path:  17%|███████████████████████▊                                                                                                                       | 3/18 [00:12<00:58,  3.91s/it, patient=周菲菲]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：周菲菲-S-73-143-J-73-304_0073.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：周菲菲-S-73-143-J-73-304_0074.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：周菲菲-S-73-143-J-73-304_0075.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/周菲菲-S-73-143-J-73-304/2/labels/周菲菲-S-73-143-J-73-304_0259.txt'\n",
      "input_path:  22%|███████████████████████████████▊                                                                                                               | 4/18 [00:15<00:49,  3.54s/it, patient=寿培旺]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/2/labels/寿培旺-J-52-115-J-222-386_0257.txt'\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 13, in find_coordinate\n",
      "    assert 0.25 < corr1[1] < 0.75 and 0.15 < corr1[2] < 0.85, f'边界框1中心({corr1[1]}, {corr1[2]})出界：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 边界框1中心(0.0117188, 0.366211)出界：寿培旺-J-52-115-J-222-386_0292.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 13, in find_coordinate\n",
      "    assert 0.25 < corr1[1] < 0.75 and 0.15 < corr1[2] < 0.85, f'边界框1中心({corr1[1]}, {corr1[2]})出界：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 边界框1中心(0.0126953, 0.363281)出界：寿培旺-J-52-115-J-222-386_0293.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 13, in find_coordinate\n",
      "    assert 0.25 < corr1[1] < 0.75 and 0.15 < corr1[2] < 0.85, f'边界框1中心({corr1[1]}, {corr1[2]})出界：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 边界框1中心(0.0146484, 0.362305)出界：寿培旺-J-52-115-J-222-386_0294.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 13, in find_coordinate\n",
      "    assert 0.25 < corr1[1] < 0.75 and 0.15 < corr1[2] < 0.85, f'边界框1中心({corr1[1]}, {corr1[2]})出界：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 边界框1中心(0.015625, 0.357422)出界：寿培旺-J-52-115-J-222-386_0295.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 13, in find_coordinate\n",
      "    assert 0.25 < corr1[1] < 0.75 and 0.15 < corr1[2] < 0.85, f'边界框1中心({corr1[1]}, {corr1[2]})出界：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 边界框1中心(0.0166016, 0.351562)出界：寿培旺-J-52-115-J-222-386_0296.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 13, in find_coordinate\n",
      "    assert 0.25 < corr1[1] < 0.75 and 0.15 < corr1[2] < 0.85, f'边界框1中心({corr1[1]}, {corr1[2]})出界：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 边界框1中心(0.0175781, 0.34668)出界：寿培旺-J-52-115-J-222-386_0297.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 13, in find_coordinate\n",
      "    assert 0.25 < corr1[1] < 0.75 and 0.15 < corr1[2] < 0.85, f'边界框1中心({corr1[1]}, {corr1[2]})出界：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 边界框1中心(0.0185547, 0.341797)出界：寿培旺-J-52-115-J-222-386_0298.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 13, in find_coordinate\n",
      "    assert 0.25 < corr1[1] < 0.75 and 0.15 < corr1[2] < 0.85, f'边界框1中心({corr1[1]}, {corr1[2]})出界：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 边界框1中心(0.0195312, 0.339844)出界：寿培旺-J-52-115-J-222-386_0299.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 13, in find_coordinate\n",
      "    assert 0.25 < corr1[1] < 0.75 and 0.15 < corr1[2] < 0.85, f'边界框1中心({corr1[1]}, {corr1[2]})出界：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 边界框1中心(0.0205078, 0.333984)出界：寿培旺-J-52-115-J-222-386_0300.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 13, in find_coordinate\n",
      "    assert 0.25 < corr1[1] < 0.75 and 0.15 < corr1[2] < 0.85, f'边界框1中心({corr1[1]}, {corr1[2]})出界：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 边界框1中心(0.0205078, 0.329102)出界：寿培旺-J-52-115-J-222-386_0301.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/2/labels/寿培旺-J-52-115-J-222-386_0304.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/2/labels/寿培旺-J-52-115-J-222-386_0305.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/2/labels/寿培旺-J-52-115-J-222-386_0307.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/2/labels/寿培旺-J-52-115-J-222-386_0308.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/2/labels/寿培旺-J-52-115-J-222-386_0309.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/2/labels/寿培旺-J-52-115-J-222-386_0310.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/2/labels/寿培旺-J-52-115-J-222-386_0311.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/2/labels/寿培旺-J-52-115-J-222-386_0312.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/2/labels/寿培旺-J-52-115-J-222-386_0317.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/2/labels/寿培旺-J-52-115-J-222-386_0319.txt'\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/2/labels/寿培旺-J-52-115-J-222-386_0366.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/2/labels/寿培旺-J-52-115-J-222-386_0367.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/2/labels/寿培旺-J-52-115-J-222-386_0385.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/2/labels/寿培旺-J-52-115-J-222-386_0386.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/2/labels/寿培旺-J-52-115-J-222-386_0387.txt'\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 3, in find_coordinate\n",
      "    with open(label_file, 'r') as f:\n",
      "FileNotFoundError: [Errno 2] No such file or directory: '/medical-data/zsxm/AorticDissection/dataset/2022-10-19/寿培旺-J-52-115-J-222-386/2/labels/寿培旺-J-52-115-J-222-386_0388.txt'\n",
      "input_path:  56%|██████████████████████████████████████████████████████████████████████████████▉                                                               | 10/18 [00:42<00:35,  4.40s/it, patient=朱俊行]]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：朱俊行-S-73-88-J-73-383_0069.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：朱俊行-S-73-88-J-73-383_0070.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：朱俊行-S-73-88-J-73-383_0071.txt\n",
      "input_path:  67%|██████████████████████████████████████████████████████████████████████████████████████████████▋                                               | 12/18 [00:52<00:29,  4.90s/it, patient=茹卫平]]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：茹卫平-S-85-97-J-85-355_0099.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：茹卫平-S-85-97-J-85-355_0100.txt\n",
      "input_path:  72%|██████████████████████████████████████████████████████████████████████████████████████████████████████▌                                       | 13/18 [00:56<00:23,  4.67s/it, patient=葛秋英]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0024.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0025.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0026.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0027.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0028.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0029.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0030.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0031.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0032.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0033.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0034.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0035.txt\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0036.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0037.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0038.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0039.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0040.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：葛秋英-S-28-111_0041.txt\n",
      "input_path:  78%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████▍                               | 14/18 [00:58<00:14,  3.60s/it, patient=董爱琴]Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0032.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0033.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0034.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0035.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0036.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0037.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0038.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0039.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0040.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0041.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0042.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0043.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0044.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0045.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0046.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0047.txt\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0048.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0049.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0050.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0051.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0052.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0053.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0054.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0055.txt\n",
      "Traceback (most recent call last):\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 60, in crop_images\n",
      "    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
      "  File \"/tmp/ipykernel_13221/1229335564.py\", line 7, in find_coordinate\n",
      "    assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
      "AssertionError: 如果只有一个label那么此时应为降主动脉, 但实际为s：董爱琴-S-36-65-J-63-286_0056.txt\n",
      "input_path: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 18/18 [01:19<00:00,  4.41s/it, patient=黄锦元]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "28 25\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "# 切出范围外冗余为3的主动脉, 疾病数据\n",
    "def find_coordinate(height, width, label_file, aorta):\n",
    "    with open(label_file, 'r') as f:\n",
    "        lines = f.readlines()\n",
    "    assert len(lines) <= 2, f'label.txt应该存储不多于2个label：{label_file.split(\"/\")[-1]}'\n",
    "    if len(lines) == 1:\n",
    "        assert aorta == 'j', f'如果只有一个label那么此时应为降主动脉, 但实际为{aorta}：{label_file.split(\"/\")[-1]}'\n",
    "        corr = list(map(lambda x: float(x), lines[0].split()))\n",
    "        x, y, w, h = corr[1], corr[2], corr[3], corr[4]\n",
    "        assert 0.25 < x < 0.75 and 0.15 < y < 0.85, f'边界框中心({x}, {y})出界：{label_file.split(\"/\")[-1]}'\n",
    "    else:\n",
    "        corr1, corr2 = list(map(lambda x: float(x), lines[0].split())), list(map(lambda x: float(x), lines[1].split()))\n",
    "        assert 0.25 < corr1[1] < 0.75 and 0.15 < corr1[2] < 0.85, f'边界框1中心({corr1[1]}, {corr1[2]})出界：{label_file.split(\"/\")[-1]}'\n",
    "        assert 0.25 < corr2[1] < 0.75 and 0.15 < corr2[2] < 0.85, f'边界框2中心({corr2[1]}, {corr2[2]})出界：{label_file.split(\"/\")[-1]}'\n",
    "        if aorta == 's':\n",
    "            x, y, w, h = (corr1[1], corr1[2], corr1[3], corr1[4]) if corr1[2] < corr2[2] else (corr2[1], corr2[2], corr2[3], corr2[4])\n",
    "        elif aorta == 'j':\n",
    "            x, y, w, h = (corr1[1], corr1[2], corr1[3], corr1[4]) if corr1[2] > corr2[2] else (corr2[1], corr2[2], corr2[3], corr2[4])\n",
    "        else:\n",
    "            raise Exception(f'aorta 应该为\"s\"或\"j\"其中之一: {label_file.split(\"/\")[-1]}')\n",
    "    w, h = int(width*w), int(height*h)\n",
    "    w, h = max(w, h), max(w, h)\n",
    "    return int(width*x-w/2), int(height*y-h/2), int(width*x+w/2+1), int(height*y+h/2+1)\n",
    "\n",
    "def crop_images(input_path, error_patient_list, cate):\n",
    "    workbook_path = os.path.join(input_path, 'label.xlsx')\n",
    "    wb = openpyxl.load_workbook(workbook_path)\n",
    "    sheet = wb['Sheet1']\n",
    "    \n",
    "    patientList = [p for p in os.listdir(input_path) if os.path.isdir(os.path.join(input_path, p))]\n",
    "    pbar = tqdm(sorted(patientList), desc=os.path.basename('input_path'))\n",
    "    for patient in pbar:\n",
    "        pbar.set_postfix({'patient': patient.split('-')[0]})\n",
    "        for row in sheet.iter_rows():\n",
    "            if row[0].value == patient.split('-')[0]:\n",
    "                plct = row[3].value.lower().split('-')\n",
    "                plcta = row[4].value.lower().split('-')\n",
    "                assert len(plct) == len(plcta), f'CT和CTA标签不等长{input_path}:{patient}, {len(plct)}, {len(plcta)}'\n",
    "                break\n",
    "        else:\n",
    "            raise ValueError(f'Cant find {patient} in label.xlsx')\n",
    "        \n",
    "        image_path = os.path.join(input_path, patient, cate, f'images_{lower_b}_{upper_b}')\n",
    "        label_path = os.path.join(input_path, patient, cate, 'labels')\n",
    "        crop_path = os.path.join(input_path, patient, cate, f'crops3d_{lower_b}_{upper_b}')\n",
    "        if os.path.exists(crop_path):\n",
    "            shutil.rmtree(crop_path)\n",
    "        os.mkdir(crop_path)\n",
    "        \n",
    "        crop_flag = True\n",
    "        cate_pl = plct if cate == '1' else plcta\n",
    "        for i, s in enumerate(cate_pl):\n",
    "            if s != 's' and s != 'j':\n",
    "                continue\n",
    "            start, end = int(cate_pl[i+1])-1, int(cate_pl[i+2])\n",
    "            for j in range(start-3, end+3):\n",
    "                try:\n",
    "                    img = Image.open(os.path.join(image_path, f'{patient}_{j:04d}.png'))\n",
    "                    img = np.array(img)\n",
    "                    x1, y1, x2, y2 = find_coordinate(*img.shape[0:2], os.path.join(label_path, f'{patient}_{j:04d}.txt'), s)\n",
    "                except:\n",
    "                    traceback.print_exc()\n",
    "                    crop_flag = False\n",
    "                else:#if crop_flag:\n",
    "                    crop = img[y1:y2, x1:x2]\n",
    "                    crop = Image.fromarray(crop)\n",
    "                    if start <= j < end:\n",
    "                        crop.save(os.path.join(crop_path, f'{patient}_{s}_{j:04d}.png'))\n",
    "                    else:\n",
    "                        crop.save(os.path.join(crop_path, f'{patient}_{s}_{j:04d}_n.png'))\n",
    "        if not crop_flag:\n",
    "            error_patient_list.append(patient)\n",
    "            \n",
    "epl1 = []\n",
    "crop_images('/medical-data/zsxm/AorticDissection/dataset/2022-09-12', epl1, '1')\n",
    "crop_images('/medical-data/zsxm/AorticDissection/dataset/2022-10-19', epl1, '1')\n",
    "epl2 = []\n",
    "crop_images('/medical-data/zsxm/AorticDissection/dataset/2022-09-12', epl2, '2')\n",
    "crop_images('/medical-data/zsxm/AorticDissection/dataset/2022-10-19', epl2, '2')\n",
    "print(len(epl1), len(epl2))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9af7801f",
   "metadata": {},
   "source": [
    "# 4.将切出的主动脉复制到一起"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "c581dded",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 30/30 [00:01<00:00, 18.80it/s]\n",
      "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:04<00:00,  4.30it/s]\n",
      "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 23/23 [00:11<00:00,  1.92it/s]\n"
     ]
    }
   ],
   "source": [
    "# 检查主动脉宽高是否相等\n",
    "dir_list = [\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/2022-09-12',\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/2022-10-19',\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative'\n",
    "]\n",
    "for ddir in dir_list:\n",
    "    for patient in tqdm(sorted(os.listdir(ddir))):\n",
    "        pdir = os.path.join(ddir, patient)\n",
    "        if os.path.isfile(pdir):\n",
    "            continue\n",
    "        for cate in ['1', '2']:\n",
    "            cdir = os.path.join(pdir, cate)\n",
    "            crop_path = os.path.join(cdir, f'crops3d_{lower_b}_{upper_b}')\n",
    "            for crop in os.listdir(crop_path):\n",
    "                croppath = os.path.join(crop_path, crop)\n",
    "                img = Image.open(croppath)\n",
    "                if img.height != img.width:\n",
    "                    print(f'{croppath}: h={img.height}, w={img.width}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "c99620cf",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "0: 2022-10-19-negative: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 23/23 [00:37<00:00,  1.64s/it]\n",
      "1: 2022-09-12: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 30/30 [00:08<00:00,  3.35it/s]\n",
      "1: 2022-10-19: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:26<00:00,  1.31s/it]\n"
     ]
    }
   ],
   "source": [
    "# 移动到一起\n",
    "dir_list = [\n",
    "    ['/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative'],\n",
    "    [\n",
    "        '/medical-data/zsxm/AorticDissection/dataset/2022-09-12',\n",
    "        '/medical-data/zsxm/AorticDissection/dataset/2022-10-19',\n",
    "    ],\n",
    "]\n",
    "dst = '/medical-data/zsxm/AorticDissection/adpaper/5independent/'\n",
    "for cate, catelist in enumerate(dir_list):\n",
    "    for ddir in catelist:\n",
    "        for patient in tqdm(sorted(os.listdir(ddir)), desc=f'{cate}: {os.path.basename(ddir)}'):\n",
    "            pdir = os.path.join(ddir, patient)\n",
    "            if os.path.isfile(pdir):\n",
    "                continue\n",
    "            for ctcate, ctdst in zip(['1', '2'], ['ct', 'cta']):\n",
    "                cdir = os.path.join(pdir, ctcate)\n",
    "                crop_path = os.path.join(cdir, f'crops3d_{lower_b}_{upper_b}')\n",
    "                dstdir = os.path.join(dst, ctdst, '3dcenter', str(cate))\n",
    "                os.makedirs(dstdir, exist_ok=True)\n",
    "                for c in os.listdir(crop_path):\n",
    "                    shutil.copy(os.path.join(crop_path, c), os.path.join(dstdir, c))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bec65053",
   "metadata": {},
   "source": [
    "# 5.测试单张图像分类准确率"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "c2f51cd8",
   "metadata": {},
   "outputs": [],
   "source": [
    "vt_list = [\n",
    "    MT.Resize3D(81),\n",
    "    MT.CenterCrop3D(81),\n",
    "    MT.ToTensor3D(),\n",
    "    MT.SobelChannel(3, flag_3d=True)\n",
    "]\n",
    "val_transform = T.Compose(vt_list)\n",
    "val_dataset = AortaDataset3DCenter(\n",
    "    '/medical-data/zsxm/AorticDissection/adpaper/5independent/cta/3dcenter',\n",
    "    cate=[0,1], transform=val_transform, depth=7, step=1)\n",
    "val_loader = DataLoader(val_dataset,\n",
    "                        batch_size=128,\n",
    "                        shuffle=False,\n",
    "                        drop_last=False,\n",
    "                        num_workers=8, \n",
    "                        pin_memory=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "395fd1e9",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                                                                                                                                                               \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "09-12_174850_3D,有Sobel,只分类阴性和夹层 report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.8776    0.6086    0.7188      6301\n",
      "           1     0.6853    0.9094    0.7816      5904\n",
      "\n",
      "    accuracy                         0.7541     12205\n",
      "   macro avg     0.7814    0.7590    0.7502     12205\n",
      "weighted avg     0.7845    0.7541    0.7491     12205\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                                                                                                                                                               \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "09-12_180329_3D,有Sobel,只分类阴性和夹层 report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.8811    0.6137    0.7235      6301\n",
      "           1     0.6886    0.9116    0.7845      5904\n",
      "\n",
      "    accuracy                         0.7578     12205\n",
      "   macro avg     0.7848    0.7626    0.7540     12205\n",
      "weighted avg     0.7880    0.7578    0.7530     12205\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                                                                                                                                                               \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "09-12_180348_3D,有Sobel,只分类阴性和夹层 report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.8960    0.5934    0.7140      6301\n",
      "           1     0.6810    0.9265    0.7850      5904\n",
      "\n",
      "    accuracy                         0.7545     12205\n",
      "   macro avg     0.7885    0.7599    0.7495     12205\n",
      "weighted avg     0.7920    0.7545    0.7483     12205\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                                                                                                                                                               \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "12-05_183652_3D,有Sobel,只分类阴性和夹层 report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.8865    0.6126    0.7245      6301\n",
      "           1     0.6891    0.9163    0.7866      5904\n",
      "\n",
      "    accuracy                         0.7595     12205\n",
      "   macro avg     0.7878    0.7645    0.7556     12205\n",
      "weighted avg     0.7910    0.7595    0.7546     12205\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                                                                                                                                                               "
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "12-05_185011_3D,有Sobel,只分类阴性和夹层 report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.9066    0.6297    0.7432      6301\n",
      "           1     0.7020    0.9307    0.8003      5904\n",
      "\n",
      "    accuracy                         0.7753     12205\n",
      "   macro avg     0.8043    0.7802    0.7718     12205\n",
      "weighted avg     0.8076    0.7753    0.7708     12205\n",
      "\n",
      "Acc: [0.754117165096272, 0.7578041786153216, 0.7545268332650553, 0.7595247849242114, 0.7753379762392462] 0.7602621876280213 0.007804108724113674\n",
      "AUC: [0.8493294043101517, 0.8382882803693138, 0.8606385713714303, 0.8443830591694268, 0.843412604099061] 0.8472103838638768 0.007573998867537952\n",
      "Sen: [0.9093834688346883, 0.9115853658536586, 0.926490514905149, 0.9163279132791328, 0.9307249322493225] 0.9189024390243903 0.008344204907562977\n",
      "Spe: [0.6086335502301222, 0.6137121091890176, 0.593397873353436, 0.6126011744167592, 0.6297413109030313] 0.6116172036184733 0.011616249615016632\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\r"
     ]
    }
   ],
   "source": [
    "device = torch.device('cuda:0')\n",
    "model_list = [\n",
    "    '.details151/CE3D/09-12_174850_3D,有Sobel,只分类阴性和夹层/Net_best.pth',\n",
    "    '.details151/CE3D/09-12_180329_3D,有Sobel,只分类阴性和夹层/Net_best.pth',\n",
    "    '.details151/CE3D/09-12_180348_3D,有Sobel,只分类阴性和夹层/Net_best.pth',\n",
    "    '.details151/CE3D/12-05_183652_3D,有Sobel,只分类阴性和夹层/Net_best.pth',\n",
    "    '.details151/CE3D/12-05_185011_3D,有Sobel,只分类阴性和夹层/Net_best.pth',\n",
    "]\n",
    "accl, aucl, senl, spel = [], [], [], []\n",
    "for model in model_list:\n",
    "    net = resnet3d(34, n_channels=2, n_classes=2, conv1_t_size=3)\n",
    "    net.load_state_dict(torch.load(model, map_location='cpu'))\n",
    "    net.to(device)\n",
    "    net.eval()\n",
    "    \n",
    "    true_list = []\n",
    "    pred_list = []\n",
    "    pred_ori_list = []\n",
    "    with torch.no_grad():\n",
    "        with tqdm(total=len(val_dataset), desc=f'independent test round', unit='img', leave=False) as pbar:\n",
    "            for imgs, labels in val_loader:\n",
    "                imgs, labels = imgs.to(device), labels.to(device)\n",
    "                preds = net(imgs)\n",
    "                pred_idx = torch.softmax(preds, dim=1)\n",
    "                pred_ori_list += pred_idx.tolist()\n",
    "                true_list += labels.tolist()\n",
    "                pred_list.extend(pred_idx.argmax(dim=1).tolist())\n",
    "                pbar.update(labels.size(0))\n",
    "    del net\n",
    "    true_list, pred_list, pred_ori_list = np.array(true_list),np.array(pred_list),np.array(pred_ori_list)\n",
    "    print(f'{os.path.basename(os.path.dirname(model))} report:\\n'+metrics.classification_report(true_list, pred_list, digits=4))\n",
    "    accl.append(metrics.accuracy_score(true_list, pred_list))\n",
    "    aucl.append(metrics.roc_auc_score(true_list, pred_ori_list[:,1]))\n",
    "    senl.append(metrics.recall_score(true_list, pred_list, pos_label=1))\n",
    "    spel.append(metrics.recall_score(true_list, pred_list, pos_label=0))\n",
    "print('Acc:', accl, np.array(accl).mean(), np.array(accl).std())\n",
    "print('AUC:', aucl, np.array(aucl).mean(), np.array(aucl).std())\n",
    "print('Sen:', senl, np.array(senl).mean(), np.array(senl).std())\n",
    "print('Spe:', spel, np.array(spel).mean(), np.array(spel).std())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "22631e0f",
   "metadata": {},
   "outputs": [],
   "source": [
    "model_list = [\n",
    "    '.details_CTA/checkpoints/CE3D/12-08_19:27:22_CTA3D,有Sobel,只分类阴性和夹层,1/Net_best.pth',\n",
    "#     '.details_CTA/checkpoints/CE3D/12-08_20:09:24_CTA3D,有Sobel,只分类阴性和夹层,2/Net_best.pth',\n",
    "#     '.details_CTA/checkpoints/CE3D/12-08_20:10:21_CTA3D,有Sobel,只分类阴性和夹层,3/Net_best.pth',\n",
    "#     '.details_CTA/checkpoints/CE3D/12-08_20:10:52_CTA3D,有Sobel,只分类阴性和夹层,4/Net_best.pth',\n",
    "#     '.details_CTA/checkpoints/CE3D/12-08_20:11:15_CTA3D,有Sobel,只分类阴性和夹层,5/Net_best.pth',\n",
    "]\n",
    "\n",
    "12-08_19:27:22_CTA3D,有Sobel,只分类阴性和夹层,1 report:\n",
    "              precision    recall  f1-score   support\n",
    "\n",
    "           0     0.9649    0.9986    0.9814      9658\n",
    "           1     0.9983    0.9580    0.9777      8355\n",
    "\n",
    "    accuracy                         0.9797     18013\n",
    "   macro avg     0.9816    0.9783    0.9796     18013\n",
    "weighted avg     0.9804    0.9797    0.9797     18013\n",
    "\n",
    "Acc: [0.979736856714595] 0.979736856714595 0.0\n",
    "AUC: [0.9990297498196551] 0.9990297498196551 0.0\n",
    "Sen: [0.9579892280071813] 0.9579892280071813 0.0\n",
    "Spe: [0.9985504245185338] 0.9985504245185338 0.0"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e89f428d",
   "metadata": {},
   "source": [
    "## 将分类错误的图片单独拷贝出来查看"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "631f9cec",
   "metadata": {},
   "outputs": [],
   "source": [
    "import re\n",
    "from os import listdir\n",
    "from os.path import join, isdir, isfile, exists\n",
    "class AortaDataset3DCenterTest(Dataset):\n",
    "    def __init__(self, img_dir, cate, transform, depth, step=1, residual=False, supcon=False, mask_dir=None):\n",
    "        self.img_dir = img_dir\n",
    "        self.transform = transform\n",
    "        assert depth % 2 == 1, 'depth should be odd number.'\n",
    "        self.depth = depth\n",
    "        self.step = step\n",
    "        self.residual = residual\n",
    "        self.supcon = supcon\n",
    "        self.mask_dir = mask_dir\n",
    "        assert not (mask_dir is None and residual == True)\n",
    "        cate = [str(i) for i in cate]\n",
    "        self.labels = sorted([label for label in listdir(img_dir) if isdir(join(img_dir, label)) and label in cate])\n",
    "        self.datas = []\n",
    "        for i, label in enumerate(self.labels):\n",
    "            img_list = sorted(list(filter(lambda x: not x.startswith('.') and isfile(join(img_dir, label, x)), listdir(join(img_dir, label)))))\n",
    "            il_len = len(img_list)\n",
    "            for j in range(il_len):\n",
    "                nl = re.split('[_.]', img_list[j])\n",
    "                assert len(nl) == 4 or len(nl) == 5, f'Format of image file name \"{img_list[j]}\" is wrong.'\n",
    "                if len(nl) == 5:\n",
    "                    continue\n",
    "                group_list = [img_list[j]]\n",
    "                half = s = depth // 2\n",
    "                for k in range(j-1, j-step*(half)-1, -1):\n",
    "                    if k < 0 or k >= il_len:\n",
    "                        for _ in range(s):\n",
    "                            group_list.insert(0, group_list[0])\n",
    "                        break\n",
    "                    nlk = re.split('[_.]', img_list[k])\n",
    "                    if nl[0] != nlk[0] or nl[1] != nlk[1]:\n",
    "                        for _ in range(s):\n",
    "                            group_list.insert(0, group_list[0])\n",
    "                        break\n",
    "                    offset = int(nl[2]) - int(nlk[2])\n",
    "                    if offset % step == 0:\n",
    "                        for _ in range(offset//step-(half-s)):\n",
    "                            group_list.insert(0, img_list[k])\n",
    "                            s -= 1\n",
    "                            if s == 0:\n",
    "                                break\n",
    "                    if s == 0:\n",
    "                        break\n",
    "                s = depth // 2\n",
    "                for k in range(j+1, j+step*(half)+1):\n",
    "                    if k < 0 or k >= il_len:\n",
    "                        for _ in range(s):\n",
    "                            group_list.insert(0, group_list[0])\n",
    "                        break\n",
    "                    nlk = re.split('[_.]', img_list[k])\n",
    "                    if nl[0] != nlk[0] or nl[1] != nlk[1]:\n",
    "                        for _ in range(s):\n",
    "                            group_list.append(group_list[-1])\n",
    "                        break\n",
    "                    offset = int(nlk[2]) - int(nl[2])\n",
    "                    if offset % step == 0:\n",
    "                        for _ in range(offset//step-(half-s)):\n",
    "                            group_list.append(img_list[k])\n",
    "                            s -= 1\n",
    "                            if s == 0:\n",
    "                                break\n",
    "                    if s == 0:\n",
    "                        break\n",
    "                assert len(group_list) == depth, f'depth wrong: {img_list[j]}'\n",
    "                if mask_dir is None:\n",
    "                    self.datas.append([[join(img_dir, label, img) for img in group_list], i])\n",
    "                else:\n",
    "                    group_mask_list = [join(mask_dir, img) if exists(join(mask_dir, img)) else None for img in group_list]\n",
    "                    self.datas.append([[join(img_dir, label, img) for img in group_list], i, group_mask_list])\n",
    "\n",
    "    def __len__(self):\n",
    "        return len(self.datas)\n",
    "\n",
    "    def __getitem__(self, index):\n",
    "        label = torch.tensor(self.datas[index][1], dtype=torch.long)\n",
    "        img_list = []\n",
    "        for img_path in self.datas[index][0]:\n",
    "            img_list.append(Image.open(img_path))\n",
    "        if self.supcon:\n",
    "            img_list1 = self.transform(img_list)\n",
    "            if self.residual:\n",
    "                for i in range(1, len(img_list1)):\n",
    "                    res = img_list1[i] - img_list1[i-1]\n",
    "                    res = (res + 1) / 2\n",
    "                    img_list1.append(res)\n",
    "            imgs1 = torch.stack(img_list1, dim=1)\n",
    "            img_list2 = self.transform(img_list)\n",
    "            if self.residual:\n",
    "                for i in range(1, len(img_list2)):\n",
    "                    res = img_list2[i] - img_list2[i-1]\n",
    "                    res = (res + 1) / 2\n",
    "                    img_list2.append(res)\n",
    "            imgs2 = torch.stack(img_list2, dim=1)\n",
    "            return [imgs1, imgs2], label\n",
    "        elif self.mask_dir is None:\n",
    "            img_list = self.transform(img_list)\n",
    "            if self.residual:\n",
    "                for i in range(1, len(img_list)):\n",
    "                    res = img_list[i] - img_list[i-1]\n",
    "                    res = (res + 1) / 2\n",
    "                    img_list.append(res)\n",
    "            imgs = torch.stack(img_list, dim=1)\n",
    "            centerimg = self.datas[index][0][len(self.datas[index][0])//2]\n",
    "            return imgs, label, centerimg\n",
    "        else:\n",
    "            mask_list = []\n",
    "            for i, mask_path in enumerate(self.datas[index][2]):\n",
    "                if mask_path is None:\n",
    "                    mask = Image.fromarray(np.ones((img_list[i].height, img_list[i].width), dtype=np.uint8)*255)\n",
    "                else:\n",
    "                    mask = Image.open(mask_path)\n",
    "                mask_list.append(mask)\n",
    "            cat_list = img_list + mask_list\n",
    "            cat_list = self.transform(cat_list)\n",
    "            img_list, mask_list = cat_list[:self.depth], cat_list[self.depth:]\n",
    "            imgs, masks = torch.stack(img_list, dim=1), torch.stack(mask_list, dim=1)\n",
    "            return imgs, label, masks"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "c832de0b",
   "metadata": {},
   "outputs": [],
   "source": [
    "vt_list = [\n",
    "    MT.Resize3D(81),\n",
    "    MT.CenterCrop3D(81),\n",
    "    MT.ToTensor3D(),\n",
    "    MT.SobelChannel(3, flag_3d=True)\n",
    "]\n",
    "val_transform = T.Compose(vt_list)\n",
    "val_dataset = AortaDataset3DCenterTest(\n",
    "    '/medical-data/zsxm/AorticDissection/adpaper/5independent/ct/3dcenter',\n",
    "    cate=[0,1], transform=val_transform, depth=7, step=1)\n",
    "val_loader = DataLoader(val_dataset,\n",
    "                        batch_size=128,\n",
    "                        shuffle=False,\n",
    "                        drop_last=False,\n",
    "                        num_workers=8, \n",
    "                        pin_memory=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "058f83e9",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                                                                                                                                     "
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "12-08_19:27:22_CTA3D,有Sobel,只分类阴性和夹层,1 report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.9649    0.9986    0.9814      9658\n",
      "           1     0.9983    0.9580    0.9777      8355\n",
      "\n",
      "    accuracy                         0.9797     18013\n",
      "   macro avg     0.9816    0.9783    0.9796     18013\n",
      "weighted avg     0.9804    0.9797    0.9797     18013\n",
      "\n",
      "Acc: [0.979736856714595] 0.979736856714595 0.0\n",
      "AUC: [0.9990300100665996] 0.9990300100665996 0.0\n",
      "Sen: [0.9579892280071813] 0.9579892280071813 0.0\n",
      "Spe: [0.9985504245185338] 0.9985504245185338 0.0\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\r"
     ]
    }
   ],
   "source": [
    "device = torch.device('cuda:2')\n",
    "model_list = [\n",
    "    '.details151/CE3D/09-12_174850_3D,有Sobel,只分类阴性和夹层/Net_best.pth',\n",
    "#     '.details151/CE3D/09-12_180329_3D,有Sobel,只分类阴性和夹层/Net_best.pth',\n",
    "#     '.details151/CE3D/09-12_180348_3D,有Sobel,只分类阴性和夹层/Net_best.pth',\n",
    "#     '.details151/CE3D/12-05_183652_3D,有Sobel,只分类阴性和夹层/Net_best.pth',\n",
    "#     '.details151/CE3D/12-05_185011_3D,有Sobel,只分类阴性和夹层/Net_best.pth',\n",
    "]\n",
    "dst_path = '/medical-data/zsxm/AorticDissection/adpaper/5independent/ct/cls_wrong'\n",
    "accl, aucl, senl, spel = [], [], [], []\n",
    "for model in model_list:\n",
    "    net = resnet3d(34, n_channels=2, n_classes=2, conv1_t_size=3)\n",
    "    net.load_state_dict(torch.load(model, map_location='cpu'))\n",
    "    net.to(device)\n",
    "    net.eval()\n",
    "    \n",
    "    true_list = []\n",
    "    pred_list = []\n",
    "    pred_ori_list = []\n",
    "    with torch.no_grad():\n",
    "        with tqdm(total=len(val_dataset), desc=f'independent test round', unit='img', leave=False) as pbar:\n",
    "            for imgs, labels, paths in val_loader:\n",
    "                imgs, labels = imgs.to(device), labels.to(device)\n",
    "                preds = net(imgs)\n",
    "                pred_ori = torch.softmax(preds, dim=1)\n",
    "                pred_ori_list += pred_ori.tolist()\n",
    "                pred_idx = pred_ori.argmax(dim=1)\n",
    "                labels_list = labels.tolist()\n",
    "                true_list += labels_list\n",
    "                pred_idx = pred_idx.tolist()\n",
    "                pred_list.extend(pred_idx)\n",
    "                for t, p, prob, pa in zip(labels_list, pred_idx, pred_ori[:,1].tolist(), paths):\n",
    "                    if t != p:\n",
    "                        os.makedirs(os.path.join(dst_path, f'{t}'), exist_ok=True)\n",
    "                        iname = f'{os.path.splitext(os.path.basename(pa))[0]}_{prob:.4f}.png'\n",
    "                        shutil.copy(pa, os.path.join(dst_path, f'{t}', iname))\n",
    "                pbar.update(labels.size(0))\n",
    "    del net\n",
    "    true_list, pred_list, pred_ori_list = np.array(true_list),np.array(pred_list),np.array(pred_ori_list)\n",
    "    print(f'{os.path.basename(os.path.dirname(model))} report:\\n'+metrics.classification_report(true_list, pred_list, digits=4))\n",
    "    accl.append(metrics.accuracy_score(true_list, pred_list))\n",
    "    aucl.append(metrics.roc_auc_score(true_list, pred_ori_list[:,1]))\n",
    "    senl.append(metrics.recall_score(true_list, pred_list, pos_label=1))\n",
    "    spel.append(metrics.recall_score(true_list, pred_list, pos_label=0))\n",
    "print('Acc:', accl, np.array(accl).mean(), np.array(accl).std())\n",
    "print('AUC:', aucl, np.array(aucl).mean(), np.array(aucl).std())\n",
    "print('Sen:', senl, np.array(senl).mean(), np.array(senl).std())\n",
    "print('Spe:', spel, np.array(spel).mean(), np.array(spel).std())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f5d4112d",
   "metadata": {},
   "source": [
    "# 6.时间测试"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "a657f24a",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 30/30 [01:17<00:00,  2.59s/it]\n",
      "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [03:47<00:00, 11.37s/it]\n",
      "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 23/23 [04:20<00:00, 11.34s/it]\n"
     ]
    }
   ],
   "source": [
    "# 测试dcm转png时间\n",
    "time_dict = {}\n",
    "dir_list = [\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/2022-09-12',\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/2022-10-19',\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative'\n",
    "]\n",
    "for ddir in dir_list:\n",
    "    for patient in tqdm(sorted(os.listdir(ddir))):\n",
    "        pdir = os.path.join(ddir, patient)\n",
    "        if os.path.isfile(pdir):\n",
    "            continue\n",
    "        for cate in ['1']:\n",
    "            cdir = os.path.join(pdir, cate)\n",
    "            image_path = os.path.join(cdir, f'images_{lower_b}_{upper_b}')\n",
    "            if os.path.exists(image_path):\n",
    "                shutil.rmtree(image_path)\n",
    "            starttime = time.time()\n",
    "            os.mkdir(image_path)\n",
    "            ct = load_scan(cdir)\n",
    "            print_flag = False\n",
    "            for i in range(len(ct)):\n",
    "                img = ct[i].pixel_array.astype(np.int16)\n",
    "                intercept = ct[i].RescaleIntercept\n",
    "                slope = ct[i].RescaleSlope\n",
    "                if slope != 1:\n",
    "                    img = (slope * img.astype(np.float64)).astype(np.int16)\n",
    "                img += np.int16(intercept)\n",
    "                img = np.clip(img, lower_b, upper_b)\n",
    "                img = ((img-lower_b)/(upper_b-lower_b)*255).astype(np.uint8)\n",
    "                img = Image.fromarray(img)\n",
    "                if img.height != img.width and not print_flag:\n",
    "                    print(f\"{patient}: height={img.height} and width={img.width} not equal.\")\n",
    "                    print_flag = True\n",
    "                img.save(os.path.join(image_path, f'{patient}_{i:04d}.png'))\n",
    "            patienttime = time.time() - starttime\n",
    "            time_dict[patient] = [len(ct), patienttime]\n",
    "torch.save(time_dict, './time_dcm2png.pth')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "fbaf2665",
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "chenjianbin-J-16-83             112  12.629773\n",
      "fangdali-S-17-26-J-18-89        121  5.022746\n",
      "heyongming-S-21-32-J-21-63       63  2.063150\n",
      "huangyuan-J-24-70                70  1.905401\n",
      "jiangyun-J-12-87                123  3.896421\n",
      "liujianping-J-16-72             116  7.741544\n",
      "liushijie-S-23-37-J-23-37       135  4.489635\n",
      "liyubing-J-13-61                 75  4.838315\n",
      "loushenghong-S-22-34            127  5.886980\n",
      "panlisheng-J-14-61              121  5.891483\n",
      "pisanxiang-J-19-24              116  8.103879\n",
      "shenchuan-S-13-19-J-13-80       121  4.332071\n",
      "wangxiangwei-J-24-25            130  8.122400\n",
      "wanshuqiao-S-24-37-J-24-91       95  2.997819\n",
      "wufu-S-23-35-J-23-94            118  5.961451\n",
      "xianianjun-J-21-73              128  9.345182\n",
      "xieyusheng-J-15-21              103  3.986480\n",
      "yangguihua-J-16-61-J-70-78      123  4.958974\n",
      "yangshiping-S-31-34-J23-91      121  5.883181\n",
      "yehui-J-14-83                   121  7.804666\n",
      "yejianfeng-J-19-101             121  8.322680\n",
      "yikeliang-J-1-55                 82  2.532496\n",
      "yushengliang-S-22-31-J-22-88    130  9.443160\n",
      "zhangguoqiang-J-19-28-J-56-66   129  4.818503\n",
      "zhangyubo-J-19-66               124  8.081485\n",
      "zhengxuyan-S-15-32-J-15-48       71  3.783376\n",
      "zhongwei-S-22-32-J-22-84        126  5.396062\n",
      "zhuguangzhong-J-41-84           121  6.730933\n",
      "于梦博-S-69-91-J-69-356            409  16.232233\n",
      "史新泉-S-71-111-J-75-413           436  21.667390\n",
      "吴银春-J-84-162-J-284-413          460  20.014038\n",
      "周菲菲-S-73-143-J-73-304           474  18.463140\n",
      "寿培旺-J-52-115-J-222-386          466  24.710133\n",
      "屠光明-J-64-382                    417  20.485952\n",
      "张彪-J-59-140-J-262-444           641  28.196130\n",
      "彭春光-J-63-158                    716  33.808369\n",
      "徐公领-J-47-427                    561  26.225246\n",
      "曹效石-S-74-98-J-74-93             368  15.085660\n",
      "朱俊行-S-73-88-J-73-383            393  13.871901\n",
      "江山-J-105-352-J-413-477          551  22.131103\n",
      "茹卫平-S-85-97-J-85-355            421  16.576253\n",
      "葛秋英-S-28-111                    410  16.371300\n",
      "董爱琴-S-36-65-J-63-286            333  15.048944\n",
      "蒋鑫毅-J-74-381                    586  19.541784\n",
      "赵善林-J-108-203-J-297-451         536  24.405535\n",
      "黄锦元-J-54-228-J-287-338          501  18.867122\n",
      "严立超-122-151-233-611             657  22.185924\n",
      "何文-40-60-116-364                496  16.822274\n",
      "俞建平-58-84-161-428               521  17.137079\n",
      "冯霞-39-57-96-293                 394  12.177719\n",
      "刘俊杰-24-42-81-321                347  11.119033\n",
      "吴张良-83-105-165-301              301  9.710833\n",
      "唐裕杰-34-56-97-325                514  16.673842\n",
      "宋大强-24-53-113-400               481  19.303502\n",
      "张文强-50-65-116-347               529  16.350135\n",
      "张琪-78-96-159-405                738  22.691834\n",
      "朱世杰-73-94-167-414               531  17.113565\n",
      "李俊梅-50-73-134-396               466  16.453002\n",
      "李百秀-43-60-108-213               213  6.636188\n",
      "李路-57-77-148-435                476  16.460881\n",
      "盛佳丽-59-77-125-288               288  9.728130\n",
      "肖来元-1-26-90-366                 551  19.718181\n",
      "蒋晓健-69-89-149-394               453  14.943552\n",
      "许希铎-88-108-154-404              449  15.222211\n",
      "陈义广-55-82-177-296               296  9.861585\n",
      "陈虎云-65-91-146-342               342  11.641563\n",
      "鲍晓力-59-84-141-357               452  17.223510\n",
      "黄晶晶-52-74-144-393               626  19.811337\n"
     ]
    }
   ],
   "source": [
    "for p, (l, t) in time_dict.items():\n",
    "    print(f'{p:30s} {l:4d}  {t:.6f}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "8575638b",
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "chenjianbin-J-16-83             112  2.862200\n",
      "fangdali-S-17-26-J-18-89        121  3.170983\n",
      "heyongming-S-21-32-J-21-63       63  1.482993\n",
      "huangyuan-J-24-70                70  1.702842\n",
      "jiangyun-J-12-87                123  2.854201\n",
      "liujianping-J-16-72             116  3.277343\n",
      "liushijie-S-23-37-J-23-37       135  3.204740\n",
      "liyubing-J-13-61                 75  1.684464\n",
      "loushenghong-S-22-34            127  2.793080\n",
      "panlisheng-J-14-61              121  3.217019\n",
      "pisanxiang-J-19-24              116  3.000390\n",
      "shenchuan-S-13-19-J-13-80       121  3.041253\n",
      "wangxiangwei-J-24-25            130  3.001327\n",
      "wanshuqiao-S-24-37-J-24-91       95  1.963858\n",
      "wufu-S-23-35-J-23-94            118  2.522006\n",
      "xianianjun-J-21-73              128  3.213215\n",
      "xieyusheng-J-15-21              103  3.007314\n",
      "yangguihua-J-16-61-J-70-78      123  2.784941\n",
      "yangshiping-S-31-34-J23-91      121  2.709975\n",
      "yehui-J-14-83                   121  2.994579\n",
      "yejianfeng-J-19-101             121  2.909294\n",
      "yikeliang-J-1-55                 82  1.985125\n",
      "yushengliang-S-22-31-J-22-88    130  2.962807\n",
      "zhangguoqiang-J-19-28-J-56-66   129  3.320969\n",
      "zhangyubo-J-19-66               124  2.925605\n",
      "zhengxuyan-S-15-32-J-15-48       71  1.629930\n",
      "zhongwei-S-22-32-J-22-84        126  2.945943\n",
      "zhuguangzhong-J-41-84           121  2.899647\n",
      "于梦博-S-69-91-J-69-356            409  10.934608\n",
      "史新泉-S-71-111-J-75-413           436  12.774317\n",
      "吴银春-J-84-162-J-284-413          460  10.065666\n",
      "周菲菲-S-73-143-J-73-304           474  11.413186\n",
      "寿培旺-J-52-115-J-222-386          466  17.029071\n",
      "屠光明-J-64-382                    417  10.846380\n",
      "张彪-J-59-140-J-262-444           641  16.369265\n",
      "彭春光-J-63-158                    716  17.915090\n",
      "徐公领-J-47-427                    561  15.670475\n",
      "曹效石-S-74-98-J-74-93             368  9.971287\n",
      "朱俊行-S-73-88-J-73-383            393  9.347362\n",
      "江山-J-105-352-J-413-477          551  12.343125\n",
      "茹卫平-S-85-97-J-85-355            421  10.314301\n",
      "葛秋英-S-28-111                    410  10.345288\n",
      "董爱琴-S-36-65-J-63-286            333  8.901887\n",
      "蒋鑫毅-J-74-381                    586  13.977197\n",
      "赵善林-J-108-203-J-297-451         536  12.753594\n",
      "黄锦元-J-54-228-J-287-338          501  12.640775\n",
      "严立超-122-151-233-611             657  16.945570\n",
      "何文-40-60-116-364                496  13.351779\n",
      "俞建平-58-84-161-428               521  12.598139\n",
      "冯霞-39-57-96-293                 394  9.055529\n",
      "刘俊杰-24-42-81-321                347  8.145458\n",
      "吴张良-83-105-165-301              301  7.266255\n",
      "唐裕杰-34-56-97-325                514  12.539576\n",
      "宋大强-24-53-113-400               481  15.468510\n",
      "张文强-50-65-116-347               529  11.945655\n",
      "张琪-78-96-159-405                738  17.206550\n",
      "朱世杰-73-94-167-414               531  12.742814\n",
      "李俊梅-50-73-134-396               466  12.662788\n",
      "李百秀-43-60-108-213               213  4.896665\n",
      "李路-57-77-148-435                476  13.042821\n",
      "盛佳丽-59-77-125-288               288  7.065328\n",
      "肖来元-1-26-90-366                 551  15.099911\n",
      "蒋晓健-69-89-149-394               453  11.032393\n",
      "许希铎-88-108-154-404              449  11.910413\n",
      "陈义广-55-82-177-296               296  7.066261\n",
      "陈虎云-65-91-146-342               342  8.290468\n",
      "鲍晓力-59-84-141-357               452  13.307365\n",
      "黄晶晶-52-74-144-393               626  14.508878\n"
     ]
    }
   ],
   "source": [
    "for p, (l, t) in time_dict.items():\n",
    "    print(f'{p:30s} {l:4d}  {t:.6f}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "37d5ad38",
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "chenjianbin-J-16-83            6.892781\n",
      "fangdali-S-17-26-J-18-89       6.904965\n",
      "heyongming-S-21-32-J-21-63     3.541545\n",
      "huangyuan-J-24-70              3.939162\n",
      "jiangyun-J-12-87               7.106788\n",
      "liujianping-J-16-72            6.014931\n",
      "liushijie-S-23-37-J-23-37      6.069679\n",
      "liyubing-J-13-61               3.714497\n",
      "loushenghong-S-22-34           5.856282\n",
      "panlisheng-J-14-61             4.957369\n",
      "pisanxiang-J-19-24             6.143412\n",
      "shenchuan-S-13-19-J-13-80      6.834361\n",
      "wangxiangwei-J-24-25           6.927588\n",
      "wanshuqiao-S-24-37-J-24-91     5.590701\n",
      "wufu-S-23-35-J-23-94           6.824111\n",
      "xianianjun-J-21-73             5.957692\n",
      "xieyusheng-J-15-21             5.037365\n",
      "yangguihua-J-16-61-J-70-78     5.830796\n",
      "yangshiping-S-31-34-J23-91     4.933598\n",
      "yehui-J-14-83                  4.477485\n",
      "yejianfeng-J-19-101            5.451089\n",
      "yikeliang-J-1-55               4.523794\n",
      "yushengliang-S-22-31-J-22-88   7.232202\n",
      "zhangguoqiang-J-19-28-J-56-66  7.048692\n",
      "zhangyubo-J-19-66              6.725302\n",
      "zhengxuyan-S-15-32-J-15-48     3.224547\n",
      "zhongwei-S-22-32-J-22-84       5.635083\n",
      "zhuguangzhong-J-41-84          5.831540\n",
      "于梦博-S-69-91-J-69-356           21.845892\n",
      "史新泉-S-71-111-J-75-413          30.542953\n",
      "吴银春-J-84-162-J-284-413         23.374899\n",
      "周菲菲-S-73-143-J-73-304          28.401809\n",
      "寿培旺-J-52-115-J-222-386         27.462379\n",
      "屠光明-J-64-382                   23.313596\n",
      "张彪-J-59-140-J-262-444          41.082837\n",
      "彭春光-J-63-158                   34.910412\n",
      "徐公领-J-47-427                   37.152916\n",
      "曹效石-S-74-98-J-74-93            20.230836\n",
      "朱俊行-S-73-88-J-73-383           25.924026\n",
      "江山-J-105-352-J-413-477         29.574697\n",
      "茹卫平-S-85-97-J-85-355           24.702973\n",
      "葛秋英-S-28-111                   25.740432\n",
      "董爱琴-S-36-65-J-63-286           17.723121\n",
      "蒋鑫毅-J-74-381                   31.577020\n",
      "赵善林-J-108-203-J-297-451        29.814410\n",
      "黄锦元-J-54-228-J-287-338         25.683820\n",
      "严立超-122-151-233-611            33.754870\n",
      "何文-40-60-116-364               24.626730\n",
      "俞建平-58-84-161-428              30.074813\n",
      "冯霞-39-57-96-293                18.045088\n",
      "刘俊杰-24-42-81-321               17.096911\n",
      "吴张良-83-105-165-301             17.417375\n",
      "唐裕杰-34-56-97-325               26.521131\n",
      "宋大强-24-53-113-400              26.700497\n",
      "张文强-50-65-116-347              33.527792\n",
      "张琪-78-96-159-405               34.109921\n",
      "朱世杰-73-94-167-414              29.614679\n",
      "李俊梅-50-73-134-396              26.000960\n",
      "李百秀-43-60-108-213              10.561928\n",
      "李路-57-77-148-435               29.796314\n",
      "盛佳丽-59-77-125-288              16.004401\n",
      "肖来元-1-26-90-366                26.288651\n",
      "蒋晓健-69-89-149-394              25.568864\n",
      "许希铎-88-108-154-404             26.166047\n",
      "陈义广-55-82-177-296              14.843872\n",
      "陈虎云-65-91-146-342              16.545632\n",
      "鲍晓力-59-84-141-357              28.667283\n",
      "黄晶晶-52-74-144-393              30.663470\n"
     ]
    }
   ],
   "source": [
    "# 测试yolo时间\n",
    "time_dict = {}\n",
    "file_list=['time_detection_2022-09-12.pth','time_detection_2022-10-19.pth','time_detection_2022-10-19-negative.pth']\n",
    "for file in file_list:\n",
    "    fold_dic = torch.load(file)\n",
    "    for k,v in fold_dic.items():\n",
    "        time_dict[k] = v\n",
    "for p, t in time_dict.items():\n",
    "    print(f'{p:30s} {t:.6f}')\n",
    "torch.save(time_dict, 'time_detection.pth')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "bda6dc9a",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " 90%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████                 | 27/30 [00:29<00:05,  1.89s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ignore zhengxuyan-S-15-32-J-15-48*2:[5]:[]\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 30/30 [00:31<00:00,  1.04s/it]\n",
      "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 21/21 [01:56<00:00,  5.55s/it]\n",
      "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 23/23 [02:04<00:00,  5.41s/it]\n"
     ]
    }
   ],
   "source": [
    "# 测试crop时间\n",
    "def total_crop(input_path, time_dict):\n",
    "    for patient in tqdm(sorted(os.listdir(input_path))):\n",
    "        patient_path = os.path.join(input_path, patient)\n",
    "        if os.path.isfile(patient_path): continue\n",
    "        for cate in ['1']:\n",
    "            if cate == '2' and not os.path.exists(os.path.join(patient_path, cate)):\n",
    "                print('ignonre 2:', patient)\n",
    "                continue\n",
    "            conti_thresh = 3 if cate == '1' else 6\n",
    "            cate_path = os.path.join(patient_path, cate)\n",
    "            image_path = os.path.join(cate_path, 'images_-100_500')\n",
    "            label_path = os.path.join(cate_path, 'labels')\n",
    "            total_crop_path = os.path.join(cate_path, 'total_crops_-100_500')\n",
    "            if os.path.exists(total_crop_path):\n",
    "                shutil.rmtree(total_crop_path)\n",
    "            \n",
    "            starttime = time.time()\n",
    "            os.mkdir(total_crop_path)\n",
    "            branch_start, branch_end = [], []\n",
    "            pre_aorta_num = 1\n",
    "            same_aorta_count = 0\n",
    "            has_change_flag = False\n",
    "            for i, label in enumerate(sorted(os.listdir(label_path))):\n",
    "                with open(os.path.join(label_path, label), 'r') as f:\n",
    "                    lines = f.readlines()\n",
    "                num = len(lines)\n",
    "                assert 0<num<3, f'{os.path.join(label_path, label)}:{num}'\n",
    "                if num == pre_aorta_num:\n",
    "                    same_aorta_count += 1\n",
    "                    if has_change_flag and same_aorta_count == conti_thresh:\n",
    "                        if num == 2:\n",
    "                            branch_start.append(i-conti_thresh+1)\n",
    "                        else:\n",
    "                            branch_end.append(i-conti_thresh+1)\n",
    "                else:\n",
    "                    has_change_flag = True\n",
    "                    pre_aorta_num = num\n",
    "                    same_aorta_count = 1\n",
    "            if cate == '1':\n",
    "                #assert len(branch_start) > 0 and len(branch_end) > 0, f'{patient}*{cate}:{branch_start}:{branch_end}'\n",
    "                if not (len(branch_start) > 0 and len(branch_end) > 0):\n",
    "                    print(f'manual set branch_start 1:{patient}*{cate}:{branch_start}:{branch_end}')\n",
    "                    branch_start = [0]\n",
    "                    branch_end = [len(os.listdir(label_path))-1]\n",
    "            else:\n",
    "                if not (len(branch_start) > 0 and len(branch_end) > 0):\n",
    "                    print(f'ignore {patient}*{cate}:{branch_start}:{branch_end}')\n",
    "                    continue\n",
    "            assert min(branch_start) >= 0, f'{patient}: {branch_start}'\n",
    "            assert max(branch_end) < len(os.listdir(label_path)), f'{patient}: {branch_end}---{len(os.listdir(label_path))}'\n",
    "            \n",
    "            branch_start = min(branch_start)\n",
    "            branch_end = min(filter(lambda x: x>branch_start, branch_end))\n",
    "            \n",
    "            j_count, s_count = 0, 0\n",
    "            for i, label in enumerate(sorted(os.listdir(label_path))):\n",
    "                if i < branch_start:\n",
    "                    continue\n",
    "                \n",
    "                with open(os.path.join(label_path, label), 'r') as f:\n",
    "                    lines = f.readlines()\n",
    "                    \n",
    "                jx, jy, jw, jh = -1, -1, -1, -1\n",
    "                sx, sy, sw, sh = -1, -1, -1, -1\n",
    "                pre_jx, pre_jy = 2, 2\n",
    "                if len(lines) == 1:\n",
    "                    corr = list(map(lambda x: float(x), lines[0].split()))\n",
    "                    jx, jy, jw, jh = corr[1], corr[2], corr[3], corr[4]\n",
    "                    if not (0.25 < jx < 0.75 and 0.15 < jy < 0.85):\n",
    "                        jx, jy, jw, jh = -1, -1, -1, -1\n",
    "                    else:\n",
    "                        pre_jx, pre_jy = jx, jy\n",
    "                else:\n",
    "                    corr = [list(map(lambda x: float(x), lines[0].split())), list(map(lambda x: float(x), lines[1].split()))]\n",
    "                    if i in range(branch_start, branch_end):\n",
    "                        sx, sy, sw, sh = (corr[0][1], corr[0][2], corr[0][3], corr[0][4]) if corr[0][2] <= corr[1][2] \\\n",
    "                            else (corr[1][1], corr[1][2], corr[1][3], corr[1][4])\n",
    "                        jx, jy, jw, jh = (corr[0][1], corr[0][2], corr[0][3], corr[0][4]) if corr[0][2] > corr[1][2] \\\n",
    "                            else (corr[1][1], corr[1][2], corr[1][3], corr[1][4])\n",
    "                        if not (0.25 < sx < 0.75 and 0.15 < sy < 0.85):\n",
    "                            sx, sy, sw, sh = -1, -1, -1, -1\n",
    "                        if not (0.25 < jx < 0.75 and 0.15 < jy < 0.85):\n",
    "                            jx, jy, jw, jh = -1, -1, -1, -1\n",
    "                    else:\n",
    "                        min_dis, min_c = float('inf'), -1\n",
    "                        for c in range(2):\n",
    "                            dis = (corr[c][1]-pre_jx)**2 + (corr[c][2]-pre_jy)**2\n",
    "                            if dis < min_dis:\n",
    "                                min_dis = dis\n",
    "                                min_c = c\n",
    "                        jx, jy, jw, jh = corr[min_c][1], corr[min_c][2], corr[min_c][3], corr[min_c][4]\n",
    "                        if not (0.25 < jx < 0.75 and 0.15 < jy < 0.85):\n",
    "                            jx, jy, jw, jh = -1, -1, -1, -1\n",
    "                        else:\n",
    "                            pre_jx, pre_jy = jx, jy\n",
    "                    \n",
    "                if jx != -1 or sx != -1:\n",
    "                    imgname = os.path.splitext(label)[0]+'.png'\n",
    "                    img = np.array(Image.open(os.path.join(image_path, imgname)))\n",
    "                    height, width = img.shape[0], img.shape[1]\n",
    "                else:\n",
    "                    continue\n",
    "                \n",
    "                if jx != -1:\n",
    "                    jw, jh = int(width*jw), int(height*jh)\n",
    "                    jw = jh = max(jw, jh)\n",
    "                    jx1, jy1, jx2, jy2 = int(width*jx-jw/2), int(height*jy-jh/2), int(width*jx+jw/2+1), int(height*jy+jh/2+1)\n",
    "                    j_crop = Image.fromarray(img[jy1:jy2, jx1:jx2])\n",
    "                    j_crop.save(os.path.join(total_crop_path, f'j_{j_count:04d}_{imgname}'))\n",
    "                    j_count += 1\n",
    "                if sx != -1:\n",
    "                    sw, sh = int(width*sw), int(height*sh)\n",
    "                    sw = sh = max(sw, sh)\n",
    "                    sx1, sy1, sx2, sy2 = int(width*sx-sw/2), int(height*sy-sh/2), int(width*sx+sw/2+1), int(height*sy+sh/2+1)\n",
    "                    s_crop = Image.fromarray(img[sy1:sy2, sx1:sx2])\n",
    "                    s_crop.save(os.path.join(total_crop_path, f's_{s_count:04d}_{imgname}'))\n",
    "                    s_count += 1\n",
    "            patienttime = time.time() - starttime\n",
    "            time_dict[patient] = patienttime\n",
    "            \n",
    "time_dict = {}\n",
    "dir_list = [\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/2022-09-12',\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/2022-10-19',\n",
    "    '/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative'\n",
    "]\n",
    "for ddir in dir_list:\n",
    "    total_crop(ddir, time_dict)\n",
    "torch.save(time_dict, './time_crop.pth')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "0a37dca7",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "22.824565649032593 12205 0.001870099602542613\n"
     ]
    }
   ],
   "source": [
    "# 测试分类推理时间时间\n",
    "vt_list = [\n",
    "    MT.Resize3D(81),\n",
    "    MT.CenterCrop3D(81),\n",
    "    MT.ToTensor3D(),\n",
    "    MT.SobelChannel(3, flag_3d=True)\n",
    "]\n",
    "val_transform = T.Compose(vt_list)\n",
    "val_dataset = AortaDataset3DCenter(\n",
    "    '/medical-data/zsxm/AorticDissection/adpaper/5independent/ct/3dcenter',\n",
    "    cate=[0,1], transform=val_transform, depth=7, step=1)\n",
    "val_loader = DataLoader(val_dataset,\n",
    "                        batch_size=128,\n",
    "                        shuffle=False,\n",
    "                        drop_last=False,\n",
    "                        num_workers=8, \n",
    "                        pin_memory=True)\n",
    "\n",
    "device = torch.device('cuda:0')\n",
    "model = '.details151/CE3D/09-12_174850_3D,有Sobel,只分类阴性和夹层/Net_best.pth'\n",
    "net = resnet3d(34, n_channels=2, n_classes=2, conv1_t_size=3)\n",
    "net.load_state_dict(torch.load(model, map_location='cpu'))\n",
    "net.to(device)\n",
    "net.eval()\n",
    "\n",
    "with torch.inference_mode():\n",
    "    with tqdm(total=len(val_dataset), desc=f'independent test round', unit='img', leave=False) as pbar:\n",
    "        starttime = time_sync()\n",
    "        for imgs, labels in val_loader:\n",
    "            imgs, labels = imgs.to(device), labels.to(device)\n",
    "            preds = net(imgs)\n",
    "            pbar.update(labels.size(0))\n",
    "        totaltime = time_sync() - starttime\n",
    "del net\n",
    "perimgclstime = totaltime/len(val_dataset)\n",
    "print(totaltime, len(val_dataset), perimgclstime)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "5e65eb24",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'严立超-122-151-233-611': 428, '何文-40-60-116-364': 299, '俞建平-58-84-161-428': 348, '冯霞-39-57-96-293': 231, '刘俊杰-24-42-81-321': 266, '吴张良-83-105-165-301': 210, '唐裕杰-34-56-97-325': 259, '宋大强-24-53-113-400': 278, '张文强-50-65-116-347': 274, '张琪-78-96-159-405': 309, '朱世杰-73-94-167-414': 324, '李俊梅-50-73-134-396': 316, '李百秀-43-60-108-213': 166, '李路-57-77-148-435': 356, '盛佳丽-59-77-125-288': 215, '肖来元-1-26-90-366': 335, '蒋晓健-69-89-149-394': 302, '许希铎-88-108-154-404': 286, '陈义广-55-82-177-296': 250, '陈虎云-65-91-146-342': 253, '鲍晓力-59-84-141-357': 274, '黄晶晶-52-74-144-393': 322, 'chenjianbin-J-16-83': 68, 'fangdali-S-17-26-J-18-89': 82, 'heyongming-S-21-32-J-21-63': 55, 'huangyuan-J-24-70': 47, 'jiangyun-J-12-87': 76, 'liujianping-J-16-72': 57, 'liushijie-S-23-37-J-23-37': 30, 'liyubing-J-13-61': 49, 'loushenghong-S-22-34': 13, 'panlisheng-J-14-61': 48, 'pisanxiang-J-19-24': 6, 'shenchuan-S-13-19-J-13-80': 75, 'wangxiangwei-J-24-25': 2, 'wanshuqiao-S-24-37-J-24-91': 82, 'wufu-S-23-35-J-23-94': 85, 'xianianjun-J-21-73': 53, 'xieyusheng-J-15-21': 7, 'yangguihua-J-16-61-J-70-78': 54, 'yangshiping-S-31-34-J23-91': 64, 'yehui-J-14-83': 70, 'yejianfeng-J-19-101': 83, 'yikeliang-J-1-55': 55, 'yushengliang-S-22-31-J-22-88': 76, 'zhangguoqiang-J-19-28-J-56-66': 21, 'zhangyubo-J-19-66': 48, 'zhengxuyan-S-15-32-J-15-48': 27, 'zhongwei-S-22-32-J-22-84': 74, 'zhuguangzhong-J-41-84': 44, '于梦博-S-69-91-J-69-356': 311, '史新泉-S-71-111-J-75-413': 380, '吴银春-J-84-162-J-284-413': 206, '周菲菲-S-73-143-J-73-304': 303, '寿培旺-J-52-115-J-222-386': 135, '屠光明-J-64-382': 319, '张彪-J-59-140-J-262-444': 264, '彭春光-J-63-158': 96, '徐公领-J-47-427': 379, '曹效石-S-74-98-J-74-93': 45, '朱俊行-S-73-88-J-73-383': 327, '江山-J-105-352-J-413-477': 313, '茹卫平-S-85-97-J-85-355': 284, '葛秋英-S-28-111': 69, '董爱琴-S-36-65-J-63-286': 236, '蒋鑫毅-J-74-381': 308, '赵善林-J-108-203-J-297-451': 251, '黄锦元-J-54-228-J-287-338': 227}\n"
     ]
    }
   ],
   "source": [
    "#统计各个病例用来分类的切片数\n",
    "countdict = {}\n",
    "for data in val_dataset.datas:\n",
    "    patient = os.path.basename(data[0][3]).split('_')[0]\n",
    "    countdict[patient] = countdict.setdefault(patient, 0) + 1\n",
    "print(countdict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "7a8386ef",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "chenjianbin-J-16-83 [112, 12.629773378372192, 6.892781496047974, 0.8422496318817139, 0.1271667729728977, 20.49197127927478]\n",
      "fangdali-S-17-26-J-18-89 [121, 5.0227460861206055, 6.904965162277222, 0.9459726810455322, 0.15334816740849427, 13.027032096851853]\n",
      "heyongming-S-21-32-J-21-63 [63, 2.06315016746521, 3.5415451526641846, 0.31467342376708984, 0.10285547813984372, 6.0222242220363285]\n",
      "huangyuan-J-24-70 [70, 1.9054014682769775, 3.939162492752075, 0.44150519371032715, 0.08789468131950282, 6.373963836058882]\n",
      "jiangyun-J-12-87 [123, 3.89642071723938, 7.10678768157959, 0.8450508117675781, 0.1421275697932386, 11.990386780379787]\n",
      "liujianping-J-16-72 [116, 7.741544246673584, 6.014930725097656, 0.8026485443115234, 0.10659567734492895, 14.665719193427693]\n",
      "liushijie-S-23-37-J-23-37 [135, 4.48963475227356, 6.069679498672485, 0.7618918418884277, 0.05610298807627839, 11.37730908091075]\n",
      "liyubing-J-13-61 [75, 4.838315486907959, 3.714496612548828, 0.5201630592346191, 0.09163488052458804, 9.164610039215994]\n",
      "loushenghong-S-22-34 [127, 5.886980056762695, 5.856281757354736, 0.6462569236755371, 0.02431129483305397, 12.413830032626024]\n",
      "panlisheng-J-14-61 [121, 5.891482830047607, 4.957369089126587, 0.8548638820648193, 0.08976478092204543, 11.79348058216106]\n",
      "pisanxiang-J-19-24 [116, 8.10387897491455, 6.143411874771118, 0.8353719711303711, 0.011220597615255679, 15.093883418431295]\n",
      "shenchuan-S-13-19-J-13-80 [121, 4.33207106590271, 6.834360837936401, 0.8389496803283691, 0.14025747019069598, 12.145639054358176]\n",
      "wangxiangwei-J-24-25 [130, 8.12239956855774, 6.92758846282959, 0.7780656814575195, 0.003740199205085226, 15.831793912049934]\n",
      "wanshuqiao-S-24-37-J-24-91 [95, 2.997819185256958, 5.59070086479187, 0.7794668674468994, 0.15334816740849427, 9.521335084904221]\n",
      "wufu-S-23-35-J-23-94 [118, 5.961450815200806, 6.824110746383667, 0.7646594047546387, 0.1589584662161221, 13.709179432555233]\n",
      "xianianjun-J-21-73 [128, 9.345181941986084, 5.957691669464111, 0.8870844841003418, 0.0991152789347585, 16.289073374485294]\n",
      "xieyusheng-J-15-21 [103, 3.986480474472046, 5.037364721298218, 0.9389491081237793, 0.013090697217798292, 9.975885001111841]\n",
      "yangguihua-J-16-61-J-70-78 [123, 4.9589738845825195, 5.830796480178833, 0.7412221431732178, 0.10098537853730111, 11.631977886471871]\n",
      "yangshiping-S-31-34-J23-91 [121, 5.883180856704712, 4.933598279953003, 0.7261695861816406, 0.11968637456272724, 11.662635097402083]\n",
      "yehui-J-14-83 [121, 7.804665565490723, 4.477485418319702, 0.8851778507232666, 0.13090697217798292, 13.298235806711673]\n",
      "yejianfeng-J-19-101 [121, 8.322680234909058, 5.4510886669158936, 0.9572188854217529, 0.1552182670110369, 14.886206054257741]\n",
      "yikeliang-J-1-55 [82, 2.532496452331543, 4.523793697357178, 0.5555882453918457, 0.10285547813984372, 7.7147338732204105]\n",
      "yushengliang-S-22-31-J-22-88 [130, 9.443159580230713, 7.23220157623291, 0.7947251796722412, 0.1421275697932386, 17.612213905929103]\n",
      "zhangguoqiang-J-19-28-J-56-66 [129, 4.818503141403198, 7.048691749572754, 0.7775053977966309, 0.039272091653394875, 12.683972380425978]\n",
      "zhangyubo-J-19-66 [124, 8.081485033035278, 6.725301504135132, 0.7511072158813477, 0.08976478092204543, 15.647658533973804]\n",
      "zhengxuyan-S-15-32-J-15-48 [71, 3.7833759784698486, 3.2245466709136963, 0.2276914119720459, 0.050492689268650554, 7.286106750624241]\n",
      "zhongwei-S-22-32-J-22-84 [126, 5.396061897277832, 5.635082721710205, 0.6759052276611328, 0.13838737058815337, 11.845437217237324]\n",
      "zhuguangzhong-J-41-84 [121, 6.730933427810669, 5.831540107727051, 0.9112229347229004, 0.08228438251187498, 13.555980852772494]\n",
      "于梦博-S-69-91-J-69-356 [409, 16.23223328590393, 21.845892190933228, 3.7190744876861572, 0.5816009763907527, 42.37880094091407]\n",
      "史新泉-S-71-111-J-75-413 [436, 21.667389631271362, 30.542953491210938, 5.139010429382324, 0.710637848966193, 58.05999140083082]\n",
      "吴银春-J-84-162-J-284-413 [460, 20.01403832435608, 23.37489938735962, 3.427537202835083, 0.3852405181237783, 47.20171543267456]\n",
      "周菲菲-S-73-143-J-73-304 [474, 18.46313977241516, 28.401808738708496, 2.8291122913360596, 0.5666401795704118, 50.26070098203013]\n",
      "寿培旺-J-52-115-J-222-386 [466, 24.710132837295532, 27.46237850189209, 2.570690155029297, 0.2524634463432528, 54.995664940560175]\n",
      "屠光明-J-64-382 [417, 20.485952138900757, 23.313596487045288, 3.554914951324463, 0.5965617732110936, 47.9510253504816]\n",
      "张彪-J-59-140-J-262-444 [641, 28.19612979888916, 41.082836627960205, 4.899823427200317, 0.49370629507124986, 74.67249614912093]\n",
      "彭春光-J-63-158 [716, 33.80836868286133, 34.91041159629822, 4.858792543411255, 0.17952956184409086, 73.75710238441489]\n",
      "徐公领-J-47-427 [561, 26.22524619102478, 37.152916431427, 5.540284872055054, 0.7087677493636504, 69.62721524387048]\n",
      "曹效石-S-74-98-J-74-93 [368, 15.085660457611084, 20.230836391448975, 3.7778005599975586, 0.08415448211441759, 39.17845189117204]\n",
      "朱俊行-S-73-88-J-73-383 [393, 13.871901035308838, 25.924026250839233, 3.963482618331909, 0.6115225700314345, 44.37093247451141]\n",
      "江山-J-105-352-J-413-477 [551, 22.131102561950684, 29.574697494506836, 4.298805475234985, 0.5853411755958379, 56.58994670728834]\n",
      "茹卫平-S-85-97-J-85-355 [421, 16.576252698898315, 24.702972650527954, 3.556636333465576, 0.5311082871221021, 45.36696997001395]\n",
      "葛秋英-S-28-111 [410, 16.371300220489502, 25.740432262420654, 3.5645413398742676, 0.1290368725754403, 45.805310695359864]\n",
      "董爱琴-S-36-65-J-63-286 [333, 15.048944234848022, 17.72312068939209, 3.6237361431121826, 0.4413435062000567, 36.83714457355235]\n",
      "蒋鑫毅-J-74-381 [586, 19.541783571243286, 31.577020406723022, 3.338853359222412, 0.5759906775831248, 55.03364801477185]\n",
      "赵善林-J-108-203-J-297-451 [536, 24.405535221099854, 29.814409732818604, 4.058720588684082, 0.4693950002381959, 58.74806054284073]\n",
      "黄锦元-J-54-228-J-287-338 [501, 18.867122411727905, 25.68381977081299, 3.818028211593628, 0.4245126097771732, 48.793483003911696]\n",
      "严立超-122-151-233-611 [657, 22.185924291610718, 33.75486969947815, 3.795175313949585, 0.8004026298882384, 60.53637193492669]\n",
      "何文-40-60-116-364 [496, 16.822274446487427, 24.626729726791382, 2.980518341064453, 0.5591597811602413, 44.9886822955035]\n",
      "俞建平-58-84-161-428 [521, 17.1370792388916, 30.0748131275177, 3.3128695487976074, 0.6507946616848294, 51.175556576891736]\n",
      "冯霞-39-57-96-293 [394, 12.177719116210938, 18.045088291168213, 2.0568132400512695, 0.43199300818734365, 32.71161365561776]\n",
      "刘俊杰-24-42-81-321 [347, 11.119032859802246, 17.096911430358887, 2.644624710083008, 0.4974464942763351, 31.358015494520476]\n",
      "吴张良-83-105-165-301 [301, 9.710832834243774, 17.41737461090088, 1.9899473190307617, 0.39272091653394875, 29.510875680709365]\n",
      "唐裕杰-34-56-97-325 [514, 16.673842191696167, 26.521130800247192, 2.5529730319976807, 0.4843557970585368, 46.232301820999574]\n",
      "宋大强-24-53-113-400 [481, 19.303502321243286, 26.700497150421143, 3.864541530609131, 0.5198876895068465, 50.388428691780405]\n",
      "张文强-50-65-116-347 [529, 16.35013484954834, 33.52779221534729, 2.4944541454315186, 0.5124072910966759, 52.88478850142383]\n",
      "张琪-78-96-159-405 [738, 22.691834449768066, 34.10992121696472, 2.5182459354400635, 0.5778607771856674, 59.89786237935852]\n",
      "朱世杰-73-94-167-414 [531, 17.11356520652771, 29.614678859710693, 2.9175045490264893, 0.6059122712238066, 50.2516608864887]\n",
      "李俊梅-50-73-134-396 [466, 16.453001737594604, 26.000960111618042, 3.055907726287842, 0.5909514744034657, 46.100821049903956]\n",
      "李百秀-43-60-108-213 [213, 6.636187553405762, 10.561928033828735, 1.4423797130584717, 0.3104365340220738, 18.950931834315043]\n",
      "李路-57-77-148-435 [476, 16.460881233215332, 29.796313762664795, 3.5998358726501465, 0.6657554585051703, 50.52278632703544]\n",
      "盛佳丽-59-77-125-288 [288, 9.728130340576172, 16.004401206970215, 2.443197727203369, 0.40207141454666184, 28.577800689296417]\n",
      "肖来元-1-26-90-366 [551, 19.718181371688843, 26.28865098953247, 3.554459810256958, 0.6264833668517754, 50.187775538330044]\n",
      "蒋晓健-69-89-149-394 [453, 14.943552494049072, 25.568864107131958, 3.1893672943115234, 0.5647700799678692, 44.266553975460425]\n",
      "许希铎-88-108-154-404 [449, 15.22221064567566, 26.16604733467102, 3.4131011962890625, 0.5348484863271874, 45.33620766296293]\n",
      "陈义广-55-82-177-296 [296, 9.861585140228271, 14.843872308731079, 2.707380533218384, 0.4675249006356533, 27.880362882813387]\n",
      "陈虎云-65-91-146-342 [342, 11.641562700271606, 16.545631885528564, 2.8711299896240234, 0.4731351994432811, 31.531459774867475]\n",
      "鲍晓力-59-84-141-357 [452, 17.223510026931763, 28.667282819747925, 3.4879188537597656, 0.5124072910966759, 49.89111899153613]\n",
      "黄晶晶-52-74-144-393 [626, 19.811336994171143, 30.663469552993774, 3.1695122718811035, 0.6021720720187214, 54.246490891064745]\n"
     ]
    }
   ],
   "source": [
    "#统计总时间消耗\n",
    "time_dict = torch.load('time_dcm2png.pth')\n",
    "tdict = torch.load('time_detection.pth')\n",
    "for k,v in time_dict.items():\n",
    "    v.append(tdict[k])\n",
    "tdict = torch.load('time_crop.pth')\n",
    "for k,v in time_dict.items():\n",
    "    v.append(tdict[k])\n",
    "    v.append(countdict[k]*perimgclstime)\n",
    "    s = 0\n",
    "    for i in range(1,5):\n",
    "        s += v[i]\n",
    "    v.append(s)\n",
    "for k,v in time_dict.items():\n",
    "    print(k, v)\n",
    "    assert len(v) == 6\n",
    "torch.save(time_dict, 'time_total.pth')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "bb0f58b3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "21943 2254.769603013992 9.73181471431422\n"
     ]
    }
   ],
   "source": [
    "slide = 0\n",
    "ttime = 0\n",
    "for k,v in time_dict.items():\n",
    "    slide += v[0]\n",
    "    ttime += v[-1]\n",
    "print(slide, ttime, slide/ttime)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "22eefc1b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "30.826727471366613"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "300/(slide/ttime)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "891e3ed3",
   "metadata": {},
   "source": [
    "# 7.stanford分型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "d7381583",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "0: 2022-10-19-negative: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 23/23 [00:45<00:00,  1.96s/it]\n",
      "1: 2022-09-12: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 30/30 [00:13<00:00,  2.25it/s]\n",
      "1: 2022-10-19: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 21/21 [00:42<00:00,  2.03s/it]\n"
     ]
    }
   ],
   "source": [
    "# 移动total_crop\n",
    "dir_list = [\n",
    "    ['/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative'],\n",
    "    [\n",
    "        '/medical-data/zsxm/AorticDissection/dataset/2022-09-12',\n",
    "        '/medical-data/zsxm/AorticDissection/dataset/2022-10-19',\n",
    "    ],\n",
    "]\n",
    "dst = '/medical-data/zsxm/AorticDissection/adpaper/5independent/scan'\n",
    "for cate, catelist in enumerate(dir_list):\n",
    "    for ddir in catelist:\n",
    "        for patient in tqdm(sorted(os.listdir(ddir)), desc=f'{cate}: {os.path.basename(ddir)}'):\n",
    "            pdir = os.path.join(ddir, patient)\n",
    "            if os.path.isfile(pdir):\n",
    "                continue\n",
    "            for ctcate, ctdst in zip(['1', '2'], ['ct', 'cta']):\n",
    "                cdir = os.path.join(pdir, ctcate)\n",
    "                crop_path = os.path.join(cdir, f'total_crops_{lower_b}_{upper_b}')\n",
    "                dstdir = os.path.join(dst, ctdst, str(cate), patient)\n",
    "                os.makedirs(dstdir, exist_ok=True)\n",
    "                if os.path.exists(dstdir):\n",
    "                    shutil.rmtree(dstdir)\n",
    "                shutil.copytree(crop_path, dstdir)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "11b27cbe",
   "metadata": {},
   "outputs": [],
   "source": [
    "#数据集\n",
    "class PatientDataset(Dataset):\n",
    "    def __init__(self, root, transform):\n",
    "        self.datas = []\n",
    "        self.transform = transform\n",
    "        for i in ['0', '1']:\n",
    "            cpath = os.path.join(root, i)\n",
    "            i = int(i)\n",
    "            for patient in sorted(os.listdir(cpath)):\n",
    "                ppath = os.path.join(cpath, patient)\n",
    "                imgs = os.listdir(ppath)\n",
    "                pd = {}\n",
    "                pd['j'] = list(map(lambda x: os.path.join(ppath, x), sorted(filter(lambda x: x.startswith('j_'), imgs))))\n",
    "                pd['s'] = list(map(lambda x: os.path.join(ppath, x), sorted(filter(lambda x: x.startswith('s_'), imgs))))\n",
    "                pd['j'] = [pd['j'][0]]*3 + pd['j'] + [pd['j'][-1]]*3\n",
    "                pd['s'] = [pd['s'][0]]*3 + pd['s'] + [pd['s'][-1]]*3\n",
    "                self.datas.append([patient, pd, i])\n",
    "        \n",
    "    def __len__(self):\n",
    "        return len(self.datas)\n",
    "        \n",
    "    def __getitem__(self, index):\n",
    "        patient, pd, label = self.datas[index]\n",
    "        jimgs = list(map(lambda x: Image.open(x), pd['j']))\n",
    "        simgs = list(map(lambda x: Image.open(x), pd['s']))\n",
    "        jimgs = self.transform(jimgs)\n",
    "        simgs = self.transform(simgs)\n",
    "        return jimgs, simgs, label, patient\n",
    "\n",
    "trans_list = [\n",
    "    MT.Resize3D(81),\n",
    "    MT.CenterCrop3D(81),\n",
    "    MT.ToTensor3D(),\n",
    "    MT.SobelChannel(3, flag_3d=True)\n",
    "]\n",
    "transform = T.Compose(trans_list)\n",
    "dataset = PatientDataset('/medical-data/zsxm/AorticDissection/adpaper/5independent/scan/ct', transform)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "11ca6a43",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "0: 2022-10-19-negative: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 23/23 [00:00<00:00, 26115.05it/s]\n",
      "1: 2022-09-12: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 30/30 [00:00<00:00, 8972.41it/s]\n",
      "1: 2022-10-19: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:00<00:00, 8778.37it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "68 {'严立超-122-151-233-611': 0, '何文-40-60-116-364': 0, '俞建平-58-84-161-428': 0, '冯霞-39-57-96-293': 0, '刘俊杰-24-42-81-321': 0, '吴张良-83-105-165-301': 0, '唐裕杰-34-56-97-325': 0, '宋大强-24-53-113-400': 0, '张文强-50-65-116-347': 0, '张琪-78-96-159-405': 0, '朱世杰-73-94-167-414': 0, '李俊梅-50-73-134-396': 0, '李百秀-43-60-108-213': 0, '李路-57-77-148-435': 0, '盛佳丽-59-77-125-288': 0, '肖来元-1-26-90-366': 0, '蒋晓健-69-89-149-394': 0, '许希铎-88-108-154-404': 0, '陈义广-55-82-177-296': 0, '陈虎云-65-91-146-342': 0, '鲍晓力-59-84-141-357': 0, '黄晶晶-52-74-144-393': 0, 'chenjianbin-J-16-83': 2, 'fangdali-S-17-26-J-18-89': 1, 'heyongming-S-21-32-J-21-63': 1, 'huangyuan-J-24-70': 2, 'jiangyun-J-12-87': 2, 'liujianping-J-16-72': 2, 'liushijie-S-23-37-J-23-37': 1, 'liyubing-J-13-61': 2, 'loushenghong-S-22-34': 1, 'panlisheng-J-14-61': 2, 'pisanxiang-J-19-24': 2, 'shenchuan-S-13-19-J-13-80': 1, 'wangxiangwei-J-24-25': 2, 'wanshuqiao-S-24-37-J-24-91': 1, 'wufu-S-23-35-J-23-94': 1, 'xianianjun-J-21-73': 2, 'xieyusheng-J-15-21': 2, 'yangguihua-J-16-61-J-70-78': 2, 'yangshiping-S-31-34-J23-91': 1, 'yehui-J-14-83': 2, 'yejianfeng-J-19-101': 2, 'yikeliang-J-1-55': 2, 'yushengliang-S-22-31-J-22-88': 1, 'zhangguoqiang-J-19-28-J-56-66': 2, 'zhangyubo-J-19-66': 2, 'zhengxuyan-S-15-32-J-15-48': 1, 'zhongwei-S-22-32-J-22-84': 1, 'zhuguangzhong-J-41-84': 2, '于梦博-S-69-91-J-69-356': 1, '史新泉-S-71-111-J-75-413': 1, '吴银春-J-84-162-J-284-413': 2, '周菲菲-S-73-143-J-73-304': 1, '寿培旺-J-52-115-J-222-386': 2, '屠光明-J-64-382': 2, '张彪-J-59-140-J-262-444': 2, '彭春光-J-63-158': 2, '徐公领-J-47-427': 2, '曹效石-S-74-98-J-74-93': 1, '朱俊行-S-73-88-J-73-383': 1, '江山-J-105-352-J-413-477': 2, '茹卫平-S-85-97-J-85-355': 1, '葛秋英-S-28-111': 1, '董爱琴-S-36-65-J-63-286': 1, '蒋鑫毅-J-74-381': 2, '赵善林-J-108-203-J-297-451': 2, '黄锦元-J-54-228-J-287-338': 2}\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "#获取每个病人的stanford分型\n",
    "stanford = {}\n",
    "dir_list = [\n",
    "    ['/medical-data/zsxm/AorticDissection/dataset/2022-10-19-negative'],\n",
    "    [\n",
    "        '/medical-data/zsxm/AorticDissection/dataset/2022-09-12',\n",
    "        '/medical-data/zsxm/AorticDissection/dataset/2022-10-19',\n",
    "    ],\n",
    "]\n",
    "for cate, catelist in enumerate(dir_list):    \n",
    "    for ddir in catelist:\n",
    "        wb = openpyxl.load_workbook(os.path.join(ddir, 'label.xlsx'))\n",
    "        st = wb['Sheet1']\n",
    "        for patient in tqdm(sorted(os.listdir(ddir)), desc=f'{cate}: {os.path.basename(ddir)}'):\n",
    "            if os.path.isfile(os.path.join(ddir,patient)):continue\n",
    "            if cate == 0:\n",
    "                stanford[patient] = 0\n",
    "            else:\n",
    "                for row in st.iter_rows():\n",
    "                    if row[0].value is not None and row[0].value == patient.split('-')[0]:\n",
    "                        stan = row[5].value.lower()\n",
    "                        if stan == 'a':\n",
    "                            stanford[patient] = 1\n",
    "                        elif stan == 'b':\n",
    "                            stanford[patient] = 2\n",
    "                        else:\n",
    "                            raise ValueError(f'{patient}: {stan}')\n",
    "                        break\n",
    "print(len(stanford),stanford)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "bfc4d1ce",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "1/1: 100%|████████| 68/68 [00:56<00:00,  1.21it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 stanford report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.0000    0.0000    0.0000        22\n",
      "           1     0.2083    0.5263    0.2985        19\n",
      "           2     0.2222    0.1481    0.1778        27\n",
      "\n",
      "    accuracy                         0.2059        68\n",
      "   macro avg     0.1435    0.2248    0.1588        68\n",
      "weighted avg     0.1464    0.2059    0.1540        68\n",
      "\n",
      "2 stanford report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.0000    0.0000    0.0000        22\n",
      "           1     0.2222    0.5263    0.3125        19\n",
      "           2     0.2857    0.2222    0.2500        27\n",
      "\n",
      "    accuracy                         0.2353        68\n",
      "   macro avg     0.1693    0.2495    0.1875        68\n",
      "weighted avg     0.1755    0.2353    0.1866        68\n",
      "\n",
      "3 stanford report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.3333    0.0455    0.0800        22\n",
      "           1     0.2381    0.5263    0.3279        19\n",
      "           2     0.3043    0.2593    0.2800        27\n",
      "\n",
      "    accuracy                         0.2647        68\n",
      "   macro avg     0.2919    0.2770    0.2293        68\n",
      "weighted avg     0.2952    0.2647    0.2287        68\n",
      "\n",
      "4 stanford report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.4000    0.0909    0.1481        22\n",
      "           1     0.2632    0.5263    0.3509        19\n",
      "           2     0.3600    0.3333    0.3462        27\n",
      "\n",
      "    accuracy                         0.3088        68\n",
      "   macro avg     0.3411    0.3169    0.2817        68\n",
      "weighted avg     0.3459    0.3088    0.2834        68\n",
      "\n",
      "5 stanford report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.3333    0.0909    0.1429        22\n",
      "           1     0.2857    0.5263    0.3704        19\n",
      "           2     0.4074    0.4074    0.4074        27\n",
      "\n",
      "    accuracy                         0.3382        68\n",
      "   macro avg     0.3422    0.3415    0.3069        68\n",
      "weighted avg     0.3494    0.3382    0.3115        68\n",
      "\n",
      "6 stanford report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.4444    0.1818    0.2581        22\n",
      "           1     0.2500    0.4211    0.3137        19\n",
      "           2     0.4074    0.4074    0.4074        27\n",
      "\n",
      "    accuracy                         0.3382        68\n",
      "   macro avg     0.3673    0.3368    0.3264        68\n",
      "weighted avg     0.3754    0.3382    0.3329        68\n",
      "\n",
      "7 stanford report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.5455    0.2727    0.3636        22\n",
      "           1     0.2333    0.3684    0.2857        19\n",
      "           2     0.4074    0.4074    0.4074        27\n",
      "\n",
      "    accuracy                         0.3529        68\n",
      "   macro avg     0.3954    0.3495    0.3523        68\n",
      "weighted avg     0.4034    0.3529    0.3592        68\n",
      "\n",
      "8 stanford report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.5000    0.2727    0.3529        22\n",
      "           1     0.2414    0.3684    0.2917        19\n",
      "           2     0.4074    0.4074    0.4074        27\n",
      "\n",
      "    accuracy                         0.3529        68\n",
      "   macro avg     0.3829    0.3495    0.3507        68\n",
      "weighted avg     0.3910    0.3529    0.3574        68\n",
      "\n",
      "9 stanford report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.5000    0.2727    0.3529        22\n",
      "           1     0.2500    0.3684    0.2979        19\n",
      "           2     0.3929    0.4074    0.4000        27\n",
      "\n",
      "    accuracy                         0.3529        68\n",
      "   macro avg     0.3810    0.3495    0.3503        68\n",
      "weighted avg     0.3876    0.3529    0.3562        68\n",
      "\n",
      "10 stanford report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.5385    0.3182    0.4000        22\n",
      "           1     0.2500    0.3684    0.2979        19\n",
      "           2     0.4074    0.4074    0.4074        27\n",
      "\n",
      "    accuracy                         0.3676        68\n",
      "   macro avg     0.3986    0.3647    0.3684        68\n",
      "weighted avg     0.4058    0.3676    0.3744        68\n",
      "\n",
      "11 stanford report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.5000    0.3182    0.3889        22\n",
      "           1     0.2917    0.3684    0.3256        19\n",
      "           2     0.4000    0.4444    0.4211        27\n",
      "\n",
      "    accuracy                         0.3824        68\n",
      "   macro avg     0.3972    0.3770    0.3785        68\n",
      "weighted avg     0.4021    0.3824    0.3840        68\n",
      "\n",
      "12 stanford report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.4667    0.3182    0.3784        22\n",
      "           1     0.2381    0.2632    0.2500        19\n",
      "           2     0.3750    0.4444    0.4068        27\n",
      "\n",
      "    accuracy                         0.3529        68\n",
      "   macro avg     0.3599    0.3419    0.3451        68\n",
      "weighted avg     0.3664    0.3529    0.3538        68\n",
      "\n",
      "13 stanford report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.4667    0.3182    0.3784        22\n",
      "           1     0.2500    0.2632    0.2564        19\n",
      "           2     0.3939    0.4815    0.4333        27\n",
      "\n",
      "    accuracy                         0.3676        68\n",
      "   macro avg     0.3702    0.3543    0.3560        68\n",
      "weighted avg     0.3773    0.3676    0.3661        68\n",
      "\n",
      "14 stanford report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.5000    0.3636    0.4211        22\n",
      "           1     0.2632    0.2632    0.2632        19\n",
      "           2     0.4242    0.5185    0.4667        27\n",
      "\n",
      "    accuracy                         0.3971        68\n",
      "   macro avg     0.3958    0.3818    0.3836        68\n",
      "weighted avg     0.4037    0.3971    0.3950        68\n",
      "\n",
      "15 stanford report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.4706    0.3636    0.4103        22\n",
      "           1     0.2632    0.2632    0.2632        19\n",
      "           2     0.4062    0.4815    0.4407        27\n",
      "\n",
      "    accuracy                         0.3824        68\n",
      "   macro avg     0.3800    0.3694    0.3714        68\n",
      "weighted avg     0.3871    0.3824    0.3812        68\n",
      "\n",
      "16 stanford report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.4500    0.4091    0.4286        22\n",
      "           1     0.2632    0.2632    0.2632        19\n",
      "           2     0.4483    0.4815    0.4643        27\n",
      "\n",
      "    accuracy                         0.3971        68\n",
      "   macro avg     0.3871    0.3846    0.3853        68\n",
      "weighted avg     0.3971    0.3971    0.3965        68\n",
      "\n",
      "17 stanford report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.4583    0.5000    0.4783        22\n",
      "           1     0.3125    0.2632    0.2857        19\n",
      "           2     0.4643    0.4815    0.4727        27\n",
      "\n",
      "    accuracy                         0.4265        68\n",
      "   macro avg     0.4117    0.4149    0.4122        68\n",
      "weighted avg     0.4199    0.4265    0.4223        68\n",
      "\n",
      "18 stanford report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.5000    0.5909    0.5417        22\n",
      "           1     0.3333    0.2632    0.2941        19\n",
      "           2     0.4815    0.4815    0.4815        27\n",
      "\n",
      "    accuracy                         0.4559        68\n",
      "   macro avg     0.4383    0.4452    0.4391        68\n",
      "weighted avg     0.4461    0.4559    0.4486        68\n",
      "\n",
      "19 stanford report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.5000    0.5909    0.5417        22\n",
      "           1     0.3571    0.2632    0.3030        19\n",
      "           2     0.4643    0.4815    0.4727        27\n",
      "\n",
      "    accuracy                         0.4559        68\n",
      "   macro avg     0.4405    0.4452    0.4391        68\n",
      "weighted avg     0.4459    0.4559    0.4476        68\n",
      "\n",
      "20 stanford report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0     0.4815    0.5909    0.5306        22\n",
      "           1     0.3571    0.2632    0.3030        19\n",
      "           2     0.4444    0.4444    0.4444        27\n",
      "\n",
      "    accuracy                         0.4412        68\n",
      "   macro avg     0.4277    0.4328    0.4260        68\n",
      "weighted avg     0.4320    0.4412    0.4328        68\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "weight_list = [\n",
    "    '.details151/CE3D/09-12_174850_3D,有Sobel,只分类阴性和夹层/Net_best.pth',\n",
    "#     '.details151/CE3D/09-12_180329_3D,有Sobel,只分类阴性和夹层/Net_best.pth',\n",
    "#     '.details151/CE3D/09-12_180348_3D,有Sobel,只分类阴性和夹层/Net_best.pth',\n",
    "#     '.details151/CE3D/12-05_183652_3D,有Sobel,只分类阴性和夹层/Net_best.pth',\n",
    "#     '.details151/CE3D/12-05_185011_3D,有Sobel,只分类阴性和夹层/Net_best.pth',\n",
    "]\n",
    "N_MAX = 20\n",
    "device = torch.device('cuda:2')\n",
    "exp_auc_list, exp_acc_list, exp_sen_list, exp_spe_list = [], [], [], []\n",
    "for iw, weight in enumerate(weight_list):\n",
    "    net = resnet3d(34, n_channels=2, n_classes=2, conv1_t_size=3)\n",
    "    net.load_state_dict(torch.load(weight, map_location=device))\n",
    "    net.to(device)\n",
    "    net.eval()\n",
    "    \n",
    "    true_list = []\n",
    "    sjpred_list = []\n",
    "    with torch.no_grad():\n",
    "        for jimgs, simgs, label, patient in tqdm(dataset, desc=f'{iw+1}/{len(weight_list)}', leave=True, ncols=50):\n",
    "            true_list.append(stanford[patient])\n",
    "            simgs = [torch.stack(simgs[i:i+7], dim=1) for i in range(len(simgs)-6)]\n",
    "            jimgs = [torch.stack(jimgs[i:i+7], dim=1) for i in range(len(jimgs)-6)]\n",
    "            imgs = torch.stack(simgs+jimgs, dim=0).to(device)\n",
    "            preds = torch.argmax(net(imgs),dim=1).tolist()\n",
    "            spreds, jpreds = preds[:len(simgs)], preds[len(simgs):]\n",
    "            sjpred_list.append( (spreds, jpreds) )\n",
    "    true_list = np.array(true_list)\n",
    "    for N in range(1, N_MAX+1):\n",
    "        pred_list = []\n",
    "        for spreds, jpreds in sjpred_list:\n",
    "            patient_label = 0\n",
    "            for isj, preds in enumerate([spreds, jpreds]):\n",
    "                pred_label = 0\n",
    "                pre = -1\n",
    "                max_len = -1\n",
    "                start_idx = -1\n",
    "                for i in range(len(preds)):\n",
    "                    cur = preds[i]\n",
    "                    if cur != pre:\n",
    "                        if pre in [1, 2]:\n",
    "                            ln = i - start_idx\n",
    "                            if ln >= N and ln > max_len:\n",
    "                                max_len = ln\n",
    "                                pred_label = pre\n",
    "                        start_idx = i\n",
    "                    pre = cur\n",
    "                if pred_label != 0:\n",
    "                    if isj == 0:\n",
    "                        patient_label = 1\n",
    "                        break\n",
    "                    else:\n",
    "                        patient_label = 2\n",
    "            pred_list.append(patient_label)\n",
    "        pred_list = np.array(pred_list)\n",
    "        print(f'{N} stanford report:\\n'+metrics.classification_report(true_list, pred_list, digits=4))\n",
    "    del net"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "488f5ba1",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
